public function MenuTreeStorage::getAllChildIds

public MenuTreeStorage::getAllChildIds($id)

Loads all the IDs for menu links that are below the given ID.

Parameters

string $id: The parent menu link ID.

Return value

array An unordered array of plugin IDs corresponding to all children.

Overrides MenuTreeStorageInterface::getAllChildIds

File

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

Class

MenuTreeStorage
Provides a menu tree storage using the database.

Namespace

Drupal\Core\Menu

Code

public function getAllChildIds($id) {
  $root = $this->loadFull($id);
  if (!$root) {
    return array();
  }
  $query = $this->connection->select($this->table, $this->options);
  $query->fields($this->table, array('id'));
  $query->condition('menu_name', $root['menu_name']);
  for ($i = 1; $i <= $root['depth']; $i++) {
    $query->condition("p$i", $root["p$i"]);
  }
  // The next p column should not be empty. This excludes the root link.
  $query->condition("p$i", 0, '>');
  return $this->safeExecuteSelect($query)->fetchAllKeyed(0, 0);
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Menu!MenuTreeStorage.php/function/MenuTreeStorage::getAllChildIds/8.1.x