public function MenuLinkContent::postSave in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/menu_link_content/src/Entity/MenuLinkContent.php \Drupal\menu_link_content\Entity\MenuLinkContent::postSave()
Acts on a saved entity before the insert or update hook is invoked.
Used after the entity is saved, but before invoking the insert or update hook. Note that in case of translatable content entities this callback is only fired on their current translation. It is up to the developer to iterate over all translations if needed.
Parameters
\Drupal\Core\Entity\EntityStorageInterface $storage: The entity storage object.
bool $update: TRUE if the entity has been updated, or FALSE if it has been inserted.
Overrides Entity::postSave
File
- core/
modules/ menu_link_content/ src/ Entity/ MenuLinkContent.php, line 195 - Contains \Drupal\menu_link_content\Entity\MenuLinkContent.
Class
- MenuLinkContent
- Defines the menu link content entity class.
Namespace
Drupal\menu_link_content\EntityCode
public function postSave(EntityStorageInterface $storage, $update = TRUE) {
parent::postSave($storage, $update);
/** @var \Drupal\Core\Menu\MenuLinkManagerInterface $menu_link_manager */
$menu_link_manager = \Drupal::service('plugin.manager.menu.link');
// The menu link can just be updated if there is already an menu link entry
// on both entity and menu link plugin level.
if ($update && $menu_link_manager
->getDefinition($this
->getPluginId())) {
// When the entity is saved via a plugin instance, we should not call
// the menu tree manager to update the definition a second time.
if (!$this->insidePlugin) {
$menu_link_manager
->updateDefinition($this
->getPluginId(), $this
->getPluginDefinition(), FALSE);
}
}
else {
$menu_link_manager
->addDefinition($this
->getPluginId(), $this
->getPluginDefinition());
}
}