You are here

protected function MenuTreeStorage::doFindChildrenRelativeDepth in Drupal 8

Same name and namespace in other branches
  1. 9 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
Finds the height of a subtree rooted by the given ID.
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 453

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, $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;
}