You are here

public function ExampleTokenEventSubscriber::tokenReplacement in Hook Event Dispatcher 8

Replace tokens.

Parameters

\Drupal\hook_event_dispatcher\Event\Token\TokensReplacementEvent $event: The token replacement event.

File

src/Example/ExampleTokenEventSubscriber.php, line 51

Class

ExampleTokenEventSubscriber
Class ExampleTokenEventSubscriber.

Namespace

Drupal\hook_event_dispatcher\Example

Code

public function tokenReplacement(TokensReplacementEvent $event) {
  if ($event
    ->forToken('node', 'serialized')) {
    $event
      ->setReplacementValue('node', 'serialized', serialize($event
      ->getData('node')));
  }
}