You are here

class Token in Flexiform 8

Provides token integration.

Hierarchy

  • class \Drupal\Core\Utility\Token
    • class \Drupal\flexiform\Utility\Token

Expanded class hierarchy of Token

4 files declare their use of Token
CustomTextComponent.php in src/Plugin/FormComponentType/CustomTextComponent.php
CustomTextComponentType.php in src/Plugin/FormComponentType/CustomTextComponentType.php
FlexiformController.php in src/Controller/FlexiformController.php
SubmitButtonRedirect.php in src/Plugin/FormEnhancer/SubmitButtonRedirect.php
1 string reference to 'Token'
flexiform.services.yml in ./flexiform.services.yml
flexiform.services.yml
1 service uses Token
flexiform.token in ./flexiform.services.yml
Drupal\flexiform\Utility\Token

File

src/Utility/Token.php, line 11

Namespace

Drupal\flexiform\Utility
View source
class Token extends CoreToken {

  /**
   * {@inheritdoc}
   *
   * Additionally this allows the user to supply aliases into options to allow
   * more than one of a given type of token.
   */
  public function generate($type, array $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) {
    if (!empty($options['alias'][$type])) {
      $unaliased_data = [
        $options['alias'][$type] => $data[$type],
      ] + $data;
      return parent::generate($options['alias'][$type], $tokens, $unaliased_data, $options, $bubbleable_metadata);
    }
    else {
      return parent::generate($type, $tokens, $data, $options, $bubbleable_metadata);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Token::$cache protected property The token cache.
Token::$cacheTagsInvalidator protected property The cache tags invalidator.
Token::$languageManager protected property The language manager.
Token::$moduleHandler protected property The module handler service.
Token::$renderer protected property The renderer.
Token::$tokenInfo protected property Token definitions.
Token::findWithPrefix public function Returns a list of tokens that begin with a specific prefix.
Token::generate public function Additionally this allows the user to supply aliases into options to allow more than one of a given type of token. Overrides Token::generate
Token::getInfo public function Returns metadata describing supported tokens.
Token::replace public function Replaces all tokens in a given string with appropriate values.
Token::resetInfo public function Resets metadata describing supported tokens.
Token::scan public function Builds a list of all token-like patterns that appear in the text.
Token::setInfo public function Sets metadata describing supported tokens.
Token::TOKEN_INFO_CACHE_TAG constant The tag to cache token info with.
Token::__construct public function Constructs a new class instance.