You are here

public function Token::substituteToken in Bamboo Twig 8.4

Same name and namespace in other branches
  1. 8.5 bamboo_twig_token/src/TwigExtension/Token.php \Drupal\bamboo_twig_token\TwigExtension\Token::substituteToken()
  2. 8.2 bamboo_twig_token/src/TwigExtension/Token.php \Drupal\bamboo_twig_token\TwigExtension\Token::substituteToken()
  3. 8.3 bamboo_twig_token/src/TwigExtension/Token.php \Drupal\bamboo_twig_token\TwigExtension\Token::substituteToken()

Substitute a given tokens with appropriate value.

Parameters

string $token: A replaceable token.

array $data: (optional) An array of keyed objects. For simple replacement scenarios 'node', 'user', and others are common keys, with an accompanying node or user object being the value. Some token types, like 'site', do not require any explicit information from $data and can be replaced even if it is empty.

array $options: (optional) A keyed array of settings and flags to control the token replacement process.

Return value

string The token value.

See also

\Drupal\Core\Utility\Token::replace()

File

bamboo_twig_token/src/TwigExtension/Token.php, line 48

Class

Token
Provides a token rempalcement as Twig Extensions.

Namespace

Drupal\bamboo_twig_token\TwigExtension

Code

public function substituteToken($token, array $data = [], array $options = []) {
  return $this
    ->getToken()
    ->replace("[{$token}]", $data, $options);
}