public function ViewProfilesPermsPermissions::permissions in View profiles permissions 2.0.x
Same name and namespace in other branches
- 8 src/ViewProfilesPermsPermissions.php \Drupal\view_profiles_perms\ViewProfilesPermsPermissions::permissions()
Get view profiles permissions.
Return value
array Permissions array.
1 string reference to 'ViewProfilesPermsPermissions::permissions'
File
- src/
ViewProfilesPermsPermissions.php, line 21
Class
- ViewProfilesPermsPermissions
- Provides the permissions for view_profile_perms module.
Namespace
Drupal\view_profiles_permsCode
public function permissions() {
// Generate permissions for each user role except authenticated and
// anonymous.
$permissions = [];
/* @var $roles \Drupal\user\RoleInterface[] */
$roles = user_roles(TRUE);
unset($roles[RoleInterface::AUTHENTICATED_ID]);
if (count($roles) < 1) {
return $permissions;
}
foreach ($roles as $role) {
$role_name = $role
->label();
$role_id = $role
->id();
$permissions["access {$role_id} users profiles"] = [
'title' => $this
->t("Access %role_name users profiles", [
'%role_name' => $role_name,
]),
];
}
return $permissions;
}