public function ExampleTokenEventSubscriber::tokenReplacement in Hook Event Dispatcher 8.2
Same name and namespace in other branches
- 3.x examples/ExampleTokenEventSubscriber.php \Drupal\hook_event_dispatcher\ExampleTokenEventSubscriber::tokenReplacement()
Replace tokens.
Parameters
\Drupal\core_event_dispatcher\Event\Token\TokensReplacementEvent $event: The token replacement event.
Throws
\UnexpectedValueException
File
- examples/
ExampleTokenEventSubscriber.php, line 65
Class
- ExampleTokenEventSubscriber
- Class ExampleTokenEventSubscriber.
Namespace
Drupal\hook_event_dispatcherCode
public function tokenReplacement(TokensReplacementEvent $event) : void {
if ($event
->forToken('node', 'serialized')) {
$event
->setReplacementValue('node', 'serialized', serialize($event
->getData('node')));
}
}