public function MenuTreeStorage::getRootPathIds in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Menu/MenuTreeStorage.php \Drupal\Core\Menu\MenuTreeStorage::getRootPathIds()
- 9 core/lib/Drupal/Core/Menu/MenuTreeStorage.php \Drupal\Core\Menu\MenuTreeStorage::getRootPathIds()
File
- core/
lib/ Drupal/ Core/ Menu/ MenuTreeStorage.php, line 778
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 [];
}