You are here

protected function MenuTreeStorage::findNoLongerExistingLinks in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Menu/MenuTreeStorage.php \Drupal\Core\Menu\MenuTreeStorage::findNoLongerExistingLinks()

Find any previously discovered menu links that no longer exist.

Parameters

array $definitions: The new menu link definitions.

Return value

array A list of menu link IDs that no longer exist.

1 call to MenuTreeStorage::findNoLongerExistingLinks()
MenuTreeStorage::rebuild in core/lib/Drupal/Core/Menu/MenuTreeStorage.php
Rebuilds the stored menu link definitions.

File

core/lib/Drupal/Core/Menu/MenuTreeStorage.php, line 1466

Class

MenuTreeStorage
Provides a menu tree storage using the database.

Namespace

Drupal\Core\Menu

Code

protected function findNoLongerExistingLinks(array $definitions) {
  if ($definitions) {
    $query = $this->connection
      ->select($this->table, NULL, $this->options);
    $query
      ->addField($this->table, 'id');
    $query
      ->condition('discovered', 1);
    $query
      ->condition('id', array_keys($definitions), 'NOT IN');

    // Starting from links with the greatest depth will minimize the amount
    // of re-parenting done by the menu storage.
    $query
      ->orderBy('depth', 'DESC');
    $result = $query
      ->execute()
      ->fetchCol();
  }
  else {
    $result = [];
  }
  return $result;
}