function MenuTreeStorage::getRootPathIds
Same name in other branches
- 8.9.x core/lib/Drupal/Core/Menu/MenuTreeStorage.php \Drupal\Core\Menu\MenuTreeStorage::getRootPathIds()
- 10 core/lib/Drupal/Core/Menu/MenuTreeStorage.php \Drupal\Core\Menu\MenuTreeStorage::getRootPathIds()
- 11.x core/lib/Drupal/Core/Menu/MenuTreeStorage.php \Drupal\Core\Menu\MenuTreeStorage::getRootPathIds()
Overrides MenuTreeStorageInterface::getRootPathIds
File
-
core/
lib/ Drupal/ Core/ Menu/ MenuTreeStorage.php, line 780
Class
- MenuTreeStorage
- Provides a menu tree storage using the database.
Namespace
Drupal\Core\MenuCode
public function getRootPathIds($id) {
$subquery = $this->connection
->select($this->table, NULL, $this->options);
// @todo Consider making this dynamic based on static::MAX_DEPTH or from the
// schema if that is generated using static::MAX_DEPTH.
// https://www.drupal.org/node/2302043
$subquery->fields($this->table, [
'p1',
'p2',
'p3',
'p4',
'p5',
'p6',
'p7',
'p8',
'p9',
]);
$subquery->condition('id', $id);
$result = current($subquery->execute()
->fetchAll(\PDO::FETCH_ASSOC));
$ids = array_filter($result);
if ($ids) {
$query = $this->connection
->select($this->table, NULL, $this->options);
$query->fields($this->table, [
'id',
]);
$query->orderBy('depth', 'DESC');
$query->condition('mlid', $ids, 'IN');
// @todo Cache this result in memory if we find it is being used more
// than once per page load. https://www.drupal.org/node/2302185
return $this->safeExecuteSelect($query)
->fetchAllKeyed(0, 0);
}
return [];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.