protected function MenuTreeStorage::doFindChildrenRelativeDepth

protected MenuTreeStorage::doFindChildrenRelativeDepth(array $original)

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.

File

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

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

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Menu!MenuTreeStorage.php/function/MenuTreeStorage::doFindChildrenRelativeDepth/8.1.x