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;
}
doc_Drupal
2016-10-29 09:27:36
Comments
Leave a Comment

Please login to continue.