You are here

public function SocialAdminMenuAdministratorMenuLinkTreeManipulators::renderForm in Open Social 8

Same name and namespace in other branches
  1. 8.9 modules/custom/social_admin_menu/src/Menu/SocialAdminMenuAdministratorMenuLinkTreeManipulators.php \Drupal\social_admin_menu\Menu\SocialAdminMenuAdministratorMenuLinkTreeManipulators::renderForm()
  2. 8.2 modules/custom/social_admin_menu/src/Menu/SocialAdminMenuAdministratorMenuLinkTreeManipulators.php \Drupal\social_admin_menu\Menu\SocialAdminMenuAdministratorMenuLinkTreeManipulators::renderForm()
  3. 8.3 modules/custom/social_admin_menu/src/Menu/SocialAdminMenuAdministratorMenuLinkTreeManipulators.php \Drupal\social_admin_menu\Menu\SocialAdminMenuAdministratorMenuLinkTreeManipulators::renderForm()
  4. 8.4 modules/custom/social_admin_menu/src/Menu/SocialAdminMenuAdministratorMenuLinkTreeManipulators.php \Drupal\social_admin_menu\Menu\SocialAdminMenuAdministratorMenuLinkTreeManipulators::renderForm()
  5. 8.5 modules/custom/social_admin_menu/src/Menu/SocialAdminMenuAdministratorMenuLinkTreeManipulators.php \Drupal\social_admin_menu\Menu\SocialAdminMenuAdministratorMenuLinkTreeManipulators::renderForm()
  6. 8.6 modules/custom/social_admin_menu/src/Menu/SocialAdminMenuAdministratorMenuLinkTreeManipulators.php \Drupal\social_admin_menu\Menu\SocialAdminMenuAdministratorMenuLinkTreeManipulators::renderForm()
  7. 8.7 modules/custom/social_admin_menu/src/Menu/SocialAdminMenuAdministratorMenuLinkTreeManipulators.php \Drupal\social_admin_menu\Menu\SocialAdminMenuAdministratorMenuLinkTreeManipulators::renderForm()
  8. 8.8 modules/custom/social_admin_menu/src/Menu/SocialAdminMenuAdministratorMenuLinkTreeManipulators.php \Drupal\social_admin_menu\Menu\SocialAdminMenuAdministratorMenuLinkTreeManipulators::renderForm()
  9. 10.3.x modules/custom/social_admin_menu/src/Menu/SocialAdminMenuAdministratorMenuLinkTreeManipulators.php \Drupal\social_admin_menu\Menu\SocialAdminMenuAdministratorMenuLinkTreeManipulators::renderForm()
  10. 10.0.x modules/custom/social_admin_menu/src/Menu/SocialAdminMenuAdministratorMenuLinkTreeManipulators.php \Drupal\social_admin_menu\Menu\SocialAdminMenuAdministratorMenuLinkTreeManipulators::renderForm()
  11. 10.1.x modules/custom/social_admin_menu/src/Menu/SocialAdminMenuAdministratorMenuLinkTreeManipulators.php \Drupal\social_admin_menu\Menu\SocialAdminMenuAdministratorMenuLinkTreeManipulators::renderForm()
  12. 10.2.x modules/custom/social_admin_menu/src/Menu/SocialAdminMenuAdministratorMenuLinkTreeManipulators.php \Drupal\social_admin_menu\Menu\SocialAdminMenuAdministratorMenuLinkTreeManipulators::renderForm()

Renders the toolbar's administration tray.

This is a adoption of core's toolbar_prerender_toolbar_administration_tray() function, which uses setMaxDepth(4) instead of setTopLevelOnly()

Return value

array The updated renderable array.

See also

admin_toolbar_prerender_toolbar_administration_tray()

File

modules/custom/social_admin_menu/src/Menu/SocialAdminMenuAdministratorMenuLinkTreeManipulators.php, line 113

Class

SocialAdminMenuAdministratorMenuLinkTreeManipulators
Provides a couple of menu link tree manipulators.

Namespace

Drupal\social_admin_menu\Menu

Code

public function renderForm() {
  $menu_tree = \Drupal::service('toolbar.menu_tree');
  $parameters = new MenuTreeParameters();
  $parameters
    ->setRoot('system.admin')
    ->excludeRoot()
    ->setMaxDepth(4)
    ->onlyEnabledLinks();
  $manipulators = [
    [
      'callable' => 'menu.default_tree_manipulators:checkAccess',
    ],
    [
      'callable' => 'menu.default_tree_manipulators:generateIndexAndSort',
    ],
    [
      'callable' => 'toolbar_tools_menu_navigation_links',
    ],
    [
      'callable' => 'social_admin_menu.administrator_menu_tree_manipulators:checkAccess',
    ],
  ];
  $tree = $menu_tree
    ->load(NULL, $parameters);
  $tree = $menu_tree
    ->transform($tree, $manipulators);
  $element['administration_menu'] = $menu_tree
    ->build($tree);
  $element['administration_menu']['#cache']['contexts'][] = 'user.roles';
  return $element;
}