function ToolbarController::preRenderAdministrationTray
Same name in other branches
- 9 core/modules/toolbar/src/Controller/ToolbarController.php \Drupal\toolbar\Controller\ToolbarController::preRenderAdministrationTray()
- 10 core/modules/toolbar/src/Controller/ToolbarController.php \Drupal\toolbar\Controller\ToolbarController::preRenderAdministrationTray()
- 11.x core/modules/toolbar/src/Controller/ToolbarController.php \Drupal\toolbar\Controller\ToolbarController::preRenderAdministrationTray()
Renders the toolbar's administration tray.
Parameters
array $element: A renderable array.
Return value
array The updated renderable array.
See also
\Drupal\Core\Render\RendererInterface::render()
1 call to ToolbarController::preRenderAdministrationTray()
- toolbar_prerender_toolbar_administration_tray in core/
modules/ toolbar/ toolbar.module - Renders the toolbar's administration tray.
File
-
core/
modules/ toolbar/ src/ Controller/ ToolbarController.php, line 68
Class
- ToolbarController
- Defines a controller for the toolbar module.
Namespace
Drupal\toolbar\ControllerCode
public static function preRenderAdministrationTray(array $element) {
$menu_tree = \Drupal::service('toolbar.menu_tree');
// Load the administrative menu. The first level is the "Administration"
// link. In order to load the children of that link, start and end on the
// second level.
$parameters = new MenuTreeParameters();
$parameters->setMinDepth(2)
->setMaxDepth(2)
->onlyEnabledLinks();
// @todo Make the menu configurable in https://www.drupal.org/node/1869638.
$tree = $menu_tree->load('admin', $parameters);
$manipulators = [
[
'callable' => 'menu.default_tree_manipulators:checkAccess',
],
[
'callable' => 'menu.default_tree_manipulators:generateIndexAndSort',
],
[
'callable' => 'toolbar_menu_navigation_links',
],
];
$tree = $menu_tree->transform($tree, $manipulators);
$element['administration_menu'] = $menu_tree->build($tree);
return $element;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.