function textimage_tokens in Textimage 8.4
Same name and namespace in other branches
- 8.3 textimage.module \textimage_tokens()
- 7.3 textimage.module \textimage_tokens()
Implements hook_tokens().
File
- ./
textimage.module, line 136 - Textimage - Provides text to image manipulations.
Code
function textimage_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) {
// Jumps out if not processing textimage tokens.
if ($type != 'textimage') {
return [];
}
// Jumps out with a warning if node is not available.
// @todo Another entity may be tokenised.
if (!isset($data['node'])) {
\Drupal::service('textimage.logger')
->warning('Textimage token(s) @tokens_list could not be resolved as no information about the context was available.', [
'@tokens_list' => implode(', ', $tokens),
]);
return [];
}
// Process tokens.
$replacements = \Drupal::service('textimage.factory')
->processTokens('url', $tokens, $data, $bubbleable_metadata);
$replacements += \Drupal::service('textimage.factory')
->processTokens('uri', $tokens, $data, $bubbleable_metadata);
return $replacements;
}