You are here

private function TokenReplacer::getTokenType in Menu Token 8

Same name and namespace in other branches
  1. 9.1.x src/Service/TokenReplacer.php \Drupal\menu_token\Service\TokenReplacer::getTokenType()

Get token type from token string.

Parameters

string $token: Token string.

Return value

mixed array.

4 calls to TokenReplacer::getTokenType()
TokenReplacer::replaceContext in src/Service/TokenReplacer.php
Replace token string with the value from context.
TokenReplacer::replaceExoticToken in src/Service/TokenReplacer.php
Replace token string with the value from global and special tokens.
TokenReplacer::replaceRandom in src/Service/TokenReplacer.php
Replace token string with the value from context.
TokenReplacer::replaceUserDefined in src/Service/TokenReplacer.php
Replace token string with the value from context.

File

src/Service/TokenReplacer.php, line 43

Class

TokenReplacer
TokenReplacer class.

Namespace

Drupal\menu_token\Service

Code

private function getTokenType($token) {
  preg_match_all('/
      \\[             # [ - pattern start
      ([^\\s\\[\\]:]+)  # match $type not containing whitespace : [ or ]
      :              # : - separator
      ([^\\[\\]]+)     # match $name not containing [ or ]
      \\]             # ] - pattern end
      /x', $token, $matches);
  $types = $matches[1];
  return $types[0];
}