You are here

public function Tracker::deleteEntity in Menu Entity Index 8

Deletes all database records for the given host entity.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The deleted host entity.

Overrides TrackerInterface::deleteEntity

1 call to Tracker::deleteEntity()
Tracker::updateEntity in src/Tracker.php
Updates database tracking for new or updated entities.

File

src/Tracker.php, line 379

Class

Tracker
Tracks menu links and their referenced entities.

Namespace

Drupal\menu_entity_index

Code

public function deleteEntity(EntityInterface $entity) {

  // Process menu links only.
  if ($entity
    ->getEntityTypeId() !== 'menu_link_content') {
    return;
  }

  // Process menu links in tracked menus only.
  if (!in_array($entity
    ->getMenuName(), $this
    ->getTrackedMenus())) {
    return;
  }
  $query = $this->database
    ->delete('menu_entity_index')
    ->condition('entity_type', $entity
    ->getEntityTypeId())
    ->condition('entity_id', $entity
    ->id());
  if ($entity
    ->getEntityType()
    ->hasKey('langcode')) {
    $query
      ->condition('langcode', $entity
      ->language()
      ->getId());
  }
  $query
    ->execute();
}