You are here

public function MongodbMenuTreeStorage::getRootPathIds in MongoDB 8

Returns all the IDs that represent the path to the root of the tree.

array(
  'p1' => 1,
  'p2' => 6,
  'p3' => 8,
  'p4' => 0,
  'p5' => 0,
  'p6' => 0,
  'p7' => 0,
  'p8' => 0,
  'p9' => 0,
);

Parameters

string $id: A menu link ID.

Return value

array An associative array of IDs with keys equal to values that represents the path from the given ID to the root of the tree. If $id is an ID that exists, the returned array will at least include it. An empty array is returned if the ID does not exist in the storage. An example $id (8) with two parents (1, 6) looks like the following:

Overrides MenuTreeStorage::getRootPathIds

File

src/MongodbMenuTreeStorage.php, line 291
Contains \Drupal\mongodb\MongodbMenuTreeStorage .

Class

MongodbMenuTreeStorage

Namespace

Drupal\mongodb

Code

public function getRootPathIds($id) {
  $p = $this
    ->mongoCollection()
    ->findOne([
    'value.id' => $id,
  ], [
    'value.p' => 1,
  ]);
  if ($p) {
    $query['value.mlid']['$in'] = $this
      ->decode128($p['value']['p']);
    return $this
      ->getIds($query, [
      'value.depth' => -1,
    ]);
  }
  return [];
}