public static function FarmAdminToolbar::preRenderTray in farmOS 2.x
Renders the farmOS toolbar's administration tray.
This is a clone of AdminToolbar::preRenderTray() method, which sets the menu root to farm.base instead of system.admin.
Parameters
array $build: A renderable array.
Return value
array The updated renderable array.
See also
\Drupal\admin_toolbar\Render\Element\AdminToolbar::preRenderTray()
File
- modules/
core/ ui/ menu/ src/ Render/ Element/ FarmAdminToolbar.php, line 36
Class
- FarmAdminToolbar
- Provides a preRenderTray() method for the toolbar that uses farm.base.
Namespace
Drupal\farm_ui_menu\Render\ElementCode
public static function preRenderTray(array $build) {
$menu_tree = \Drupal::service('toolbar.menu_tree');
$parameters = new MenuTreeParameters();
$parameters
->setRoot('farm.base')
->excludeRoot()
->setMaxDepth(4)
->onlyEnabledLinks();
$tree = $menu_tree
->load(NULL, $parameters);
$manipulators = [
[
'callable' => 'menu.default_tree_manipulators:checkAccess',
],
[
'callable' => 'menu.default_tree_manipulators:generateIndexAndSort',
],
[
'callable' => 'toolbar_tools_menu_navigation_links',
],
];
$tree = $menu_tree
->transform($tree, $manipulators);
$build['administration_menu'] = $menu_tree
->build($tree);
return $build;
}