getRootPathIds example


  public function countMenuLinks($menu_name = NULL) {
    return $this->treeStorage->countMenuLinks($menu_name);
  }

  /** * {@inheritdoc} */
  public function getParentIds($id) {
    if ($this->getDefinition($id, FALSE)) {
      return $this->treeStorage->getRootPathIds($id);
    }
    return NULL;
  }

  /** * {@inheritdoc} */
  public function getChildIds($id) {
    if ($this->getDefinition($id, FALSE)) {
      return $this->treeStorage->getAllChildIds($id);
    }
    
// Put the current link onto the front.     array_unshift($parents$raw['id']);

    $query = $this->connection->select('menu_tree');
    $query->fields('menu_tree', ['id', 'mlid']);
    $query->condition('id', $parents, 'IN');
    $found_parents = $query->execute()->fetchAllKeyed(0, 1);

    $this->assertSameSize($parents$found_parents, 'Found expected number of parents');
    $this->assertCount($raw['depth']$found_parents, 'Number of parents is the same as the depth');

    $materialized_path = $this->treeStorage->getRootPathIds($id);
    $this->assertEquals(array_values($parents)array_values($materialized_path), 'Parents match the materialized path');
    // Check that the selected mlid values of the parents are in the correct     // column, including the link's own.     for ($i = $raw['depth']$i >= 1; $i--) {
      $parent_id = array_shift($parents);
      $this->assertEquals($found_parents[$parent_id]$raw["p{$i}"], "mlid of parent matches at column p{$i}");
    }
    for ($i = $raw['depth'] + 1; $i <= $this->treeStorage->maxDepth()$i++) {
      $this->assertEquals(0, $raw["p{$i}"], "parent is 0 at column p{$i} greater than depth");
    }
    if ($parents) {
      
Home | Imprint | This part of the site doesn't use cookies.