You are here

public function EntityHooks::onNodeDelete in Entity Reference Hierarchy 3.x

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

React to node delete.

Parameters

\Drupal\node\NodeInterface $node: Node update.

File

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

Class

EntityHooks
Defines a class for entity hooks for the module.

Namespace

Drupal\entity_hierarchy_microsite

Code

public function onNodeDelete(NodeInterface $node) {
  foreach ($this->parentCandidate
    ->getCandidateFields($node) as $field) {
    if ($this
      ->getMicrositesForNodeAndField($node, $field)) {
      $plugin_id = 'entity_hierarchy_microsite:' . $node
        ->uuid();
      if ($this->menuLinkManager
        ->hasDefinition($plugin_id)) {
        $this->menuLinkManager
          ->removeDefinition($plugin_id);
        continue;
      }
    }
  }
}