function tokenuuid_tokens in Token UUID 8
Implements hook_tokens().
Parameters
string $type machine name of the group (type):
array $tokens tokens to be replaced.:
array $data An associative array of data objects:
array $options An associative array of options for token replacement:
\Drupal\Core\Render\BubbleableMetadata $bubbleableMetadata:
Return value
array associative keyed by [type:token] strings
File
- ./
tokenuuid.module, line 57 - Contains tokenuuid.module.
Code
function tokenuuid_tokens($type, $tokens, array $data, array $options, \Drupal\Core\Render\BubbleableMetadata $bubbleableMetadata) {
foreach (tokenuuid_get_contententitytype_id() as $entity_id) {
if ($type == $entity_id && !empty($data[$entity_id])) {
$entity = $data[$entity_id];
$replaced = [];
foreach ($tokens as $name => $original) {
if ($name == 'uuid') {
$replaced[$original] = $entity
->uuid();
}
}
return $replaced;
}
}
}