MenuTreeStorage::loadAllChildren

public MenuTreeStorage::loadAllChildren($id, $max_relative_depth = NULL)

Loads all the enabled menu links that are below the given ID.

The returned links are not ordered, and visible children will be included even if they have parent that is not enabled or ancestor so would not normally appear in a rendered tree.

Parameters

string $id: The parent menu link ID.

int $max_relative_depth: The maximum relative depth of the children relative to the passed parent.

Return value

array An array of enabled link definitions, keyed by ID.

Overrides MenuTreeStorageInterface::loadAllChildren

File

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

Class

MenuTreeStorage
Provides a menu tree storage using the database.

Namespace

Drupal\Core\Menu

Code

public function loadAllChildren($id, $max_relative_depth = NULL) {
  $parameters = new MenuTreeParameters();
  $parameters->setRoot($id)->excludeRoot()->setMaxDepth($max_relative_depth)->onlyEnabledLinks();
  $links = $this->loadLinks(NULL, $parameters);
  foreach ($links as $id => $link) {
    $links[$id] = $this->prepareLink($link);
  }
  return $links;
}
doc_Drupal
2016-10-29 09:27:38
Comments
Leave a Comment

Please login to continue.