class Token in Bamboo Twig 8.2
Same name and namespace in other branches
- 8.5 bamboo_twig_token/src/TwigExtension/Token.php \Drupal\bamboo_twig_token\TwigExtension\Token
- 8.3 bamboo_twig_token/src/TwigExtension/Token.php \Drupal\bamboo_twig_token\TwigExtension\Token
- 8.4 bamboo_twig_token/src/TwigExtension/Token.php \Drupal\bamboo_twig_token\TwigExtension\Token
Provides a token rempalcement as Twig Extensions.
Hierarchy
- class \Drupal\bamboo_twig\TwigExtension\TwigExtensionBase extends \Drupal\bamboo_twig\TwigExtension\Twig_Extension uses \Symfony\Component\DependencyInjection\ContainerAwareTrait
- class \Drupal\bamboo_twig_token\TwigExtension\Token
Expanded class hierarchy of Token
1 string reference to 'Token'
- bamboo_twig_token.services.yml in bamboo_twig_token/
bamboo_twig_token.services.yml - bamboo_twig_token/bamboo_twig_token.services.yml
1 service uses Token
File
- bamboo_twig_token/
src/ TwigExtension/ Token.php, line 10
Namespace
Drupal\bamboo_twig_token\TwigExtensionView source
class Token extends TwigExtensionBase {
/**
* List of all Twig functions.
*/
public function getFunctions() {
return [
new \Twig_SimpleFunction('bamboo_token', [
$this,
'substituteToken',
]),
];
}
/**
* Unique identifier for this Twig extension.
*/
public function getName() {
return 'bamboo_twig_token.twig.token';
}
/**
* Substitute a given tokens with appropriate value.
*
* @param string $token
* A replaceable token.
* @param 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.
* @param array $options
* (optional) A keyed array of settings and flags to control the token
* replacement process.
*
* @return string
* The token value.
*
* @see \Drupal\Core\Utility\Token::replace()
*/
public function substituteToken($token, array $data = [], array $options = []) {
return $this
->getToken()
->replace("[{$token}]", $data, $options);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Token:: |
public | function | List of all Twig functions. | |
Token:: |
public | function |
Unique identifier for this Twig extension. Overrides TwigExtensionBase:: |
|
Token:: |
public | function | Substitute a given tokens with appropriate value. | |
TwigExtensionBase:: |
protected | function | Return the block storage. | |
TwigExtensionBase:: |
protected | function | Provides an interface for a configuration object factory. | |
TwigExtensionBase:: |
protected | function | Return the current route match. | |
TwigExtensionBase:: |
protected | function | Lazy loading for the Drupal current user account proxy. | |
TwigExtensionBase:: |
protected | function | Provides a service to handle various date related functionality. | |
TwigExtensionBase:: |
protected | function | Lazy loading for the Drupal entity type manager. | |
TwigExtensionBase:: |
protected | function | Return a singleton mime type to file extension guesser. | |
TwigExtensionBase:: |
protected | function | Return the factory for image objects. | |
TwigExtensionBase:: |
protected | function | Return the file storage. | |
TwigExtensionBase:: |
protected | function | Provides helpers to operate on files and stream wrappers. | |
TwigExtensionBase:: |
protected | function | Provides an interface for form building and processing. | |
TwigExtensionBase:: |
protected | function | Return the factory for image objects. | |
TwigExtensionBase:: |
protected | function | Provides an interface defining an image style. | |
TwigExtensionBase:: |
protected | function | Returns the language manager service. | |
TwigExtensionBase:: |
protected | function | Interface for loading, transforming and rendering menu link trees. | |
TwigExtensionBase:: |
protected | function | Manages discovery and instantiation of block plugins. | |
TwigExtensionBase:: |
protected | function | Read only settings singleton. | |
TwigExtensionBase:: |
protected | function | The state storage service. | |
TwigExtensionBase:: |
protected | function | Return the token service. | |
TwigExtensionBase:: |
protected | function | Return the user storage. |