function ModulePermissionsLinkHelper::getModulePermissionsLink
Same name in other branches
- 11.x core/modules/user/src/ModulePermissionsLinkHelper.php \Drupal\user\ModulePermissionsLinkHelper::getModulePermissionsLink()
Generates a link pointing to a given module's permissions page section.
Parameters
string $module: The module name.
string $name: The module display name.
Return value
array|null A module permissions link as a render array or NULL if the module doesn't expose any permission or the current user cannot access it.
File
-
core/
modules/ user/ src/ ModulePermissionsLinkHelper.php, line 47
Class
- ModulePermissionsLinkHelper
- Provides a helper for generating module permissions links.
Namespace
Drupal\userCode
public function getModulePermissionsLink(string $module, string $name) : ?array {
if ($this->permissionHandler
->moduleProvidesPermissions($module)) {
if ($this->accessManager
->checkNamedRoute('user.admin_permissions.module', [
'modules' => $module,
])) {
$url = new Url('user.admin_permissions.module', [
'modules' => $module,
]);
return [
'title' => t('Configure @module permissions', [
'@module' => $name,
]),
'description' => '',
'url' => $url,
];
}
}
return NULL;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.