function scheduled_transitions_tokens in Scheduled Transitions 8
Same name and namespace in other branches
- 2.x scheduled_transitions.module \scheduled_transitions_tokens()
Implements hook_tokens().
File
- ./
scheduled_transitions.module, line 176
Code
function scheduled_transitions_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) {
$replacements = [];
$scheduledTransitionData = $data['scheduled-transitions'] ?? NULL;
if ($type == 'scheduled-transitions' && $scheduledTransitionData) {
foreach ($tokens as $name => $original) {
switch ($name) {
case 'to-state':
$replacements[$original] = $scheduledTransitionData['to-state'];
break;
case 'from-state':
$replacements[$original] = $scheduledTransitionData['from-state'];
break;
case 'from-revision-id':
$replacements[$original] = $scheduledTransitionData['from-revision-id'];
break;
case 'latest-state':
$replacements[$original] = $scheduledTransitionData['latest-state'];
break;
case 'latest-revision-id':
$replacements[$original] = $scheduledTransitionData['latest-revision-id'];
break;
}
}
}
return $replacements;
}