function MenuTreeStorage::doFindChildrenRelativeDepth

Same name in other branches
  1. 9 core/lib/Drupal/Core/Menu/MenuTreeStorage.php \Drupal\Core\Menu\MenuTreeStorage::doFindChildrenRelativeDepth()
  2. 8.9.x core/lib/Drupal/Core/Menu/MenuTreeStorage.php \Drupal\Core\Menu\MenuTreeStorage::doFindChildrenRelativeDepth()
  3. 11.x core/lib/Drupal/Core/Menu/MenuTreeStorage.php \Drupal\Core\Menu\MenuTreeStorage::doFindChildrenRelativeDepth()

Finds the relative depth of this link's deepest child.

Parameters

array $original: The parent definition used to find the depth.

Return value

int Returns the relative depth.

2 calls to MenuTreeStorage::doFindChildrenRelativeDepth()
MenuTreeStorage::getSubtreeHeight in core/lib/Drupal/Core/Menu/MenuTreeStorage.php
MenuTreeStorage::setParents in core/lib/Drupal/Core/Menu/MenuTreeStorage.php
Sets the materialized path field values based on the parent.

File

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

Class

MenuTreeStorage
Provides a menu tree storage using the database.

Namespace

Drupal\Core\Menu

Code

protected function doFindChildrenRelativeDepth(array $original) {
    $query = $this->connection
        ->select($this->table, NULL, $this->options);
    $query->addField($this->table, 'depth');
    $query->condition('menu_name', $original['menu_name']);
    $query->orderBy('depth', 'DESC');
    $query->range(0, 1);
    for ($i = 1; $i <= static::MAX_DEPTH && $original["p{$i}"]; $i++) {
        $query->condition("p{$i}", $original["p{$i}"]);
    }
    $max_depth = $this->safeExecuteSelect($query)
        ->fetchField();
    return $max_depth > $original['depth'] ? $max_depth - $original['depth'] : 0;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.