function WorkspacesHooks::menuLinkContentUpdate
Implements hook_ENTITY_TYPE_update() for the 'menu_link_content' entity type.
File
-
core/
modules/ workspaces/ src/ Hook/ WorkspacesHooks.php, line 205
Class
- WorkspacesHooks
- Hook implementations for workspaces.
Namespace
Drupal\workspaces\HookCode
public function menuLinkContentUpdate(EntityInterface $entity) {
/** @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(),
], '.');
\Drupal::service('cache_tags.invalidator')->invalidateTags($cache_tags);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.