class EntityQueuePermissions in Entityqueue 8
Provides dynamic permissions for the Entityqueue module.
Hierarchy
- class \Drupal\entityqueue\EntityQueuePermissions uses StringTranslationTrait
Expanded class hierarchy of EntityQueuePermissions
File
- src/
EntityQueuePermissions.php, line 11
Namespace
Drupal\entityqueueView source
class EntityQueuePermissions {
use StringTranslationTrait;
/**
* Returns an array of queue permissions.
*
* @return array
*/
public function permissions() {
$perms = [];
// Generate queue permissions for all queues.
foreach (EntityQueue::loadMultiple() as $queue) {
$perms += $this
->buildPermissions($queue);
}
return $perms;
}
/**
* Returns a set of permissions for a specific queue.
*
* @param \Drupal\entityqueue\Entity\EntityQueue $queue
* An EntityQueue entity.
*
* @return array
*/
public function buildPermissions(EntityQueue $queue) {
$queue_id = $queue
->id();
if ($queue
->getHandlerPlugin()
->supportsMultipleSubqueues()) {
$permissions["create {$queue_id} entityqueue"] = [
'title' => $this
->t('Add %queue subqueues', [
'%queue' => $queue
->label(),
]),
'description' => $this
->t('Access to create new subqueue to the %queue queue.', [
'%queue' => $queue
->label(),
]),
];
$permissions["delete {$queue_id} entityqueue"] = [
'title' => $this
->t('Delete %queue subqueues', [
'%queue' => $queue
->label(),
]),
'description' => $this
->t('Access to delete subqueues of the %queue queue.', [
'%queue' => $queue
->label(),
]),
];
}
$permissions["update {$queue_id} entityqueue"] = [
'title' => $this
->t('Manipulate %queue queue', [
'%queue' => $queue
->label(),
]),
'description' => $this
->t('Access to update the %queue queue.', [
'%queue' => $queue
->label(),
]),
];
return $permissions;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EntityQueuePermissions:: |
public | function | Returns a set of permissions for a specific queue. | |
EntityQueuePermissions:: |
public | function | Returns an array of queue 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. |