diff --git a/admin_toolbar.module b/admin_toolbar.module index cd57c20..ce747aa 100644 --- a/admin_toolbar.module +++ b/admin_toolbar.module @@ -21,13 +21,15 @@ function admin_toolbar_toolbar_alter(&$items) { */ function admin_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->setRoot('system.admin')->excludeRoot()->setMaxDepth(4)->onlyEnabledLinks(); - $tree = $menu_tree->load(NULL, $parameters); + $parameters->setMinDepth(2)->setMaxDepth(4)->onlyEnabledLinks(); + $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'), + array('callable' => 'menu.default_tree_manipulators:checkAccess'), + array('callable' => 'menu.default_tree_manipulators:generateIndexAndSort'), ); $tree = $menu_tree->transform($tree, $manipulators); $element['administration_menu'] = $menu_tree->build($tree); diff --git a/admin_toolbar_tools/admin_toolbar_tools.module b/admin_toolbar_tools/admin_toolbar_tools.module index ba13106..4abe149 100644 --- a/admin_toolbar_tools/admin_toolbar_tools.module +++ b/admin_toolbar_tools/admin_toolbar_tools.module @@ -13,7 +13,7 @@ use Drupal\Core\Routing\RouteMatchInterface; function admin_toolbar_tools_toolbar() { $items = array(); $items['admin_toolbar_tools'] = array( - '#type' => 'toolbar_item', + '#type' => 'link', '#attributes' => array( 'class' => array('toolbar-icon', 'toolbar-icon-admin-toolbar-tools-help'), ), @@ -21,8 +21,9 @@ function admin_toolbar_tools_toolbar() { 'library' => array( 'admin_toolbar_tools/toolbar.icon', ), - ), + ),s ); + return $items; } @@ -43,7 +44,6 @@ function admin_toolbar_tools_help($route_name, RouteMatchInterface $route_match) * Implements hook_menu_links_discovered_alter(). */ function admin_toolbar_tools_menu_links_discovered_alter(&$links) { - $links['admin_toolbar_tools.help'] = array( 'title' => 'Tools', 'route_name' => '', diff --git a/admin_toolbar_tools/src/Tests/AdminToolbarToolsAlterTest.php b/admin_toolbar_tools/src/Tests/AdminToolbarToolsAlterTest.php index 00cf9e1..4a89a00 100644 --- a/admin_toolbar_tools/src/Tests/AdminToolbarToolsAlterTest.php +++ b/admin_toolbar_tools/src/Tests/AdminToolbarToolsAlterTest.php @@ -44,7 +44,7 @@ class AdminToolbarToolsAlterTest extends WebTestBase { function testAdminToolbarTools() { // Test for admin_toolbar_tools if special menu items are added. - $this->assertRaw('id="toolbar-link-admin_toolbar_tools-flush"'); + $this->assertRaw('class="toolbar-icon toolbar-icon-admin-toolbar-tools-help"'); } diff --git a/src/Tests/AdminToolbarAlterTest.php b/src/Tests/AdminToolbarAlterTest.php index f67f9c6..9818c78 100644 --- a/src/Tests/AdminToolbarAlterTest.php +++ b/src/Tests/AdminToolbarAlterTest.php @@ -45,7 +45,7 @@ class AdminToolbarAlterTest extends WebTestBase { // Assert that expanded links are present in HTML. // Test with the site configuration link that must be there whatever modules exists. - $this->assertRaw('id="toolbar-link-system-admin_config_system"'); + $this->assertRaw('data-drupal-link-system-path="admin/config/system"'); } }