class ContactPermissionsPermissions in Contact Permissions 8.2
Same name and namespace in other branches
- 8 src/ContactPermissionsPermissions.php \Drupal\contact_permissions\ContactPermissionsPermissions
Provides the permissions for accessing per role contact forms.
Hierarchy
- class \Drupal\contact_permissions\ContactPermissionsPermissions uses StringTranslationTrait
Expanded class hierarchy of ContactPermissionsPermissions
File
- src/
ContactPermissionsPermissions.php, line 10
Namespace
Drupal\contact_permissionsView source
class ContactPermissionsPermissions {
use StringTranslationTrait;
/**
* Get access per role contact forms permissions.
*
* @return array
* Permissions array.
*/
public function permissions() {
// Generate permissions for each user role.
$permissions = [];
/* @var \Drupal\user\RoleInterface[] $roles */
$roles = user_roles(TRUE);
if (count($roles) < 1) {
return $permissions;
}
foreach ($roles as $role) {
$role_name = $role
->label();
$role_id = $role
->id();
$permissions["use {$role_id} personal contact forms"] = [
'title' => $this
->t("Use %role_name's personal contact forms", [
'%role_name' => $role_name,
]),
];
}
return $permissions;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ContactPermissionsPermissions:: |
public | function | Get access per role contact forms permissions. | |
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. |