You are here

public static function Link::postDelete in Colossal Menu 8

Same name and namespace in other branches
  1. 2.x src/Entity/Link.php \Drupal\colossal_menu\Entity\Link::postDelete()

Update the link tree.

Overrides EntityBase::postDelete

File

src/Entity/Link.php, line 167

Class

Link
Defines the Link entity.

Namespace

Drupal\colossal_menu\Entity

Code

public static function postDelete(EntityStorageInterface $storage, array $entities) {
  $connection = \Drupal::service('database');
  foreach ($entities as $entity) {
    $query = $connection
      ->delete('colossal_menu_link_tree');
    $or = new Condition('OR');
    $or
      ->condition('ancestor', $entity
      ->id());
    $or
      ->condition('descendant', $entity
      ->id());
    $query
      ->condition($or);
    $query
      ->execute();
  }
  return parent::postDelete($storage, $entities);
}