toolbar_prerender_toolbar_administration_tray

toolbar_prerender_toolbar_administration_tray(array $element)

Renders the toolbar's administration tray.

Parameters

array $element: A renderable array.

Return value

array The updated renderable array.

See also

drupal_render()

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

Please login to continue.