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
File
- core/modules/toolbar/toolbar.module, line 222
- Administration toolbar for quick access to top level administration items.
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 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 ; } |
Please login to continue.