class PermissionGenerator in Role Delegation 8
The PermissionGenerator class.
Hierarchy
- class \Drupal\role_delegation\PermissionGenerator uses StringTranslationTrait
Expanded class hierarchy of PermissionGenerator
1 file declares its use of PermissionGenerator
- RoleDelegationAccessCheck.php in src/
Access/ RoleDelegationAccessCheck.php
1 string reference to 'PermissionGenerator'
1 service uses PermissionGenerator
File
- src/
PermissionGenerator.php, line 10
Namespace
Drupal\role_delegationView source
class PermissionGenerator {
use StringTranslationTrait;
/**
* The delegatable role service for getting all the roles.
*
* @var \Drupal\role_delegation\DelegatableRolesInterface
*/
protected $delegatableRoles;
/**
* Construct a new permission generator.
*
* @param \Drupal\role_delegation\DelegatableRolesInterface $delegatable_roles
* The delegatable roles service.
*/
public function __construct(DelegatableRolesInterface $delegatable_roles) {
$this->delegatableRoles = $delegatable_roles;
}
/**
* Returns an array of permissions to assign specific roles.
*
* @return array
* An array of permissions in the correct format for permission_callbacks.
*/
public function rolePermissions() {
$permissions = [];
foreach ($this->delegatableRoles
->getAllRoles() as $rid => $role) {
$permissions[sprintf('assign %s role', $rid)] = [
'title' => $this
->t('Assign %role role', [
'%role' => $role
->label(),
]),
];
}
return $permissions;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PermissionGenerator:: |
protected | property | The delegatable role service for getting all the roles. | |
PermissionGenerator:: |
public | function | Returns an array of permissions to assign specific roles. | |
PermissionGenerator:: |
public | function | Construct a new permission generator. | |
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. |