You are here

function admin_toolbar_prerender_toolbar_administration_tray in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 modules/admin_toolbar/admin_toolbar.module \admin_toolbar_prerender_toolbar_administration_tray()

Renders the toolbar's administration tray. This is a clone of core's toolbar_prerender_toolbar_administration_tray() function, which uses setMaxDepth(4) instead of setTopLevelOnly()

Parameters

array $element: A renderable array.

Return value

array The updated renderable array.

See also

toolbar_prerender_toolbar_administration_tray()

1 string reference to 'admin_toolbar_prerender_toolbar_administration_tray'
admin_toolbar_toolbar_alter in modules/admin_toolbar/admin_toolbar.module
Implements hook_toolbar_alter().

File

modules/admin_toolbar/admin_toolbar.module, line 22

Code

function admin_toolbar_prerender_toolbar_administration_tray(array $element) {
  $menu_tree = \Drupal::service('toolbar.menu_tree');
  $parameters = new MenuTreeParameters();
  $parameters
    ->setRoot('system.admin')
    ->excludeRoot()
    ->setMaxDepth(4)
    ->onlyEnabledLinks();
  $tree = $menu_tree
    ->load(NULL, $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;
}