You are here

function token_module_test_node_presave in Token 8

Implements hook_ENTITY_TYPE_presave for Node entities.

File

tests/modules/token_module_test/token_module_test.module, line 26
Helper module for token tests.

Code

function token_module_test_node_presave(NodeInterface $node) {

  // Transform tokens in the body.
  // @see \Drupal\token\Tests\TokenMenuTest::testMenuTokens()
  if ($node
    ->hasField('body')) {
    $node->body->value = \Drupal::token()
      ->replace($node->body->value, [
      'node' => $node,
    ]);
  }
}