function WorkspacesHooks::menuLinkContentUpdate

Implements hook_ENTITY_TYPE_update() for 'menu_link_content' entities.

Attributes

#[Hook('menu_link_content_update')]

File

core/modules/workspaces/src/Hook/WorkspacesHooks.php, line 68

Class

WorkspacesHooks
Hook implementations for workspaces.

Namespace

Drupal\workspaces\Hook

Code

public function menuLinkContentUpdate(EntityInterface $entity) : void {
  /** @var \Drupal\menu_link_content\MenuLinkContentInterface $entity */
  if ($entity->getLoadedRevisionId() != $entity->getRevisionId()) {
    // We are not updating the menu tree definitions when a custom menu link
    // entity is saved as a pending revision (because the parent can not be
    // changed), so we need to clear the system menu cache manually. However,
    // inserting or deleting a custom menu link updates the menu tree
    // definitions, so we don't have to do anything in those cases.
    $cache_tags = Cache::buildTags('config:system.menu', [
      $entity->getMenuName(),
    ], '.');
    $this->cacheTagsInvalidator
      ->invalidateTags($cache_tags);
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.