system_get_module_admin_tasks($module, array $info)
Generate a list of tasks offered by a specified module.
Parameters
string $module: Module name.
array $info: The module's information, as provided by system_get_info().
Return value
array An array of task links.
File
- core/modules/system/system.module, line 1211
- Configuration system that lets administrators modify the workings of the site.
Code
function system_get_module_admin_tasks($module, array $info) { $tree = &drupal_static(__FUNCTION__); $menu_tree = \Drupal::menuTree(); if (!isset($tree)) { $parameters = new MenuTreeParameters(); $parameters->setRoot('system.admin')->excludeRoot()->onlyEnabledLinks(); $tree = $menu_tree->load('system.admin', $parameters); $manipulators = array( array('callable' => 'menu.default_tree_manipulators:checkAccess'), array('callable' => 'menu.default_tree_manipulators:generateIndexAndSort'), array('callable' => 'menu.default_tree_manipulators:flatten'), ); $tree = $menu_tree->transform($tree, $manipulators); } $admin_tasks = array(); foreach ($tree 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. continue; } $link = $element->link; if ($link->getProvider() != $module) { continue; } $admin_tasks[] = array( 'title' => $link->getTitle(), 'description' => $link->getDescription(), 'url' => $link->getUrlObject(), ); } // Append link for permissions. /** @var \Drupal\user\PermissionHandlerInterface $permission_handler */ $permission_handler = \Drupal::service('user.permissions'); if ($permission_handler->moduleProvidesPermissions($module)) { /** @var \Drupal\Core\Access\AccessManagerInterface $access_manager */ $access_manager = \Drupal::service('access_manager'); if ($access_manager->checkNamedRoute('user.admin_permissions', array(), \Drupal::currentUser())) { /** @var \Drupal\Core\Url $url */ $url = new Url('user.admin_permissions'); $url->setOption('fragment', 'module-' . $module); $admin_tasks["user.admin_permissions.$module"] = array( 'title' => t('Configure @module permissions', array('@module' => $info['name'])), 'description' => '', 'url' => $url, ); } } return $admin_tasks; }
Please login to continue.