You are here

function toolbar_prerender_toolbar_administration_tray in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/toolbar/toolbar.module \toolbar_prerender_toolbar_administration_tray()

Renders the toolbar's administration tray.

Parameters

array $element: A renderable array.

Return value

array The updated renderable array.

See also

drupal_render()

1 string reference to 'toolbar_prerender_toolbar_administration_tray'
toolbar_toolbar in core/modules/toolbar/toolbar.module
Implements hook_toolbar().

File

core/modules/toolbar/toolbar.module, line 222
Administration toolbar for quick access to top level administration items.

Code

function toolbar_prerender_toolbar_administration_tray(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 = array(
    array(
      'callable' => 'menu.default_tree_manipulators:checkAccess',
    ),
    array(
      'callable' => 'menu.default_tree_manipulators:generateIndexAndSort',
    ),
    array(
      'callable' => 'toolbar_menu_navigation_links',
    ),
  );
  $tree = $menu_tree
    ->transform($tree, $manipulators);
  $element['administration_menu'] = $menu_tree
    ->build($tree);
  return $element;
}