class ViewProfilesPermsPermissions in View profiles permissions 8
Same name and namespace in other branches
- 2.0.x src/ViewProfilesPermsPermissions.php \Drupal\view_profiles_perms\ViewProfilesPermsPermissions
Provides the permissions for view_profile_perms module.
Hierarchy
- class \Drupal\view_profiles_perms\ViewProfilesPermsPermissions uses StringTranslationTrait
Expanded class hierarchy of ViewProfilesPermsPermissions
File
- src/
ViewProfilesPermsPermissions.php, line 11
Namespace
Drupal\view_profiles_permsView source
class ViewProfilesPermsPermissions {
use StringTranslationTrait;
/**
* Get view profiles permissions.
*
* @return array
* Permissions array.
*/
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;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
ViewProfilesPermsPermissions:: |
public | function | Get view profiles permissions. |