You are here

protected function EntityHooks::updateMenuForMicrosite in Entity Reference Hierarchy 8.2

Same name and namespace in other branches
  1. 3.x modules/entity_hierarchy_microsite/src/EntityHooks.php \Drupal\entity_hierarchy_microsite\EntityHooks::updateMenuForMicrosite()

Updates menu for the microsite.

Parameters

\Drupal\entity_hierarchy_microsite\Entity\MicrositeInterface $microsite: Microsite.

3 calls to EntityHooks::updateMenuForMicrosite()
EntityHooks::onMicrositePostSave in modules/entity_hierarchy_microsite/src/EntityHooks.php
React to microsite being saved.
EntityHooks::onNodeInsert in modules/entity_hierarchy_microsite/src/EntityHooks.php
React to node insert.
EntityHooks::onNodeUpdate in modules/entity_hierarchy_microsite/src/EntityHooks.php
React to node update.

File

modules/entity_hierarchy_microsite/src/EntityHooks.php, line 184

Class

EntityHooks
Defines a class for entity hooks for the module.

Namespace

Drupal\entity_hierarchy_microsite

Code

protected function updateMenuForMicrosite(MicrositeInterface $microsite) {
  foreach ($this->menuLinkDiscovery
    ->getMenuLinkDefintions($microsite) as $uuid => $definition) {
    $plugin_id = 'entity_hierarchy_microsite:' . $uuid;
    if ($this->menuLinkManager
      ->hasDefinition($plugin_id)) {
      $this->menuLinkManager
        ->updateDefinition($plugin_id, $definition, FALSE);
      continue;
    }
    $this->menuLinkManager
      ->addDefinition($plugin_id, $definition);
  }
}