You are here

function token_node_insert in Token 8

Implements hook_ENTITY_TYPE_insert for node entities.

File

./token.module, line 758
Enhances the token API in core: adds a browseable UI, missing tokens, etc.

Code

function token_node_insert(NodeInterface $node) {
  if ($node
    ->hasField('menu_link') && ($menu_link = $node->menu_link->entity)) {

    // Update the menu-link to point to the now saved node.
    $menu_link->link = 'entity:node/' . $node
      ->id();
    $menu_link
      ->save();
  }
}