memoryCache->get(self::ADMIN_LINKS_MENU_TREE); if ($cacheItem) { $menuTree = $cacheItem->data; } else { $parameters = (new MenuTreeParameters()) ->setRoot('system.admin') ->excludeRoot() ->onlyEnabledLinks(); $menuTree = $this->menuLinkTree->load('system.admin', $parameters); $manipulators = [ ['callable' => 'menu.default_tree_manipulators:checkAccess'], ['callable' => 'menu.default_tree_manipulators:generateIndexAndSort'], ['callable' => 'menu.default_tree_manipulators:flatten'], ]; $menuTree = $this->menuLinkTree->transform($menuTree, $manipulators); $this->memoryCache->set(self::ADMIN_LINKS_MENU_TREE, $menuTree); } $admin_tasks = []; foreach ($menuTree as $element) { if (!$element->access->isAllowed()) { // @todo Bubble cacheability metadata of both accessible and // inaccessible links. Currently made impossible by the way admin // tasks are rendered. See https://www.drupal.org/node/2488958 continue; } $link = $element->link; if ($link->getProvider() !== $module) { continue; } $admin_tasks[] = [ 'title' => $link->getTitle(), 'description' => $link->getDescription(), 'url' => $link->getUrlObject(), ]; } return $admin_tasks; } }