class Permissions in Workflows Field 2.x
Same name and namespace in other branches
- 8 src/Permissions.php \Drupal\workflows_field\Permissions
Defines a class for dynamic permissions based on transitions.
@internal
Hierarchy
- class \Drupal\workflows_field\Permissions uses StringTranslationTrait
Expanded class hierarchy of Permissions
File
- src/
Permissions.php, line 13
Namespace
Drupal\workflows_fieldView source
class Permissions {
use StringTranslationTrait;
/**
* Returns an array of permissions.
*
* @return array
* The dynamic permissions.
*/
public function getPermissions() {
$permissions = [];
/** @var \Drupal\workflows\WorkflowInterface $workflow */
foreach (Workflow::loadMultipleByType('workflows_field') as $id => $workflow) {
foreach ($workflow
->getTypePlugin()
->getTransitions() as $transition) {
$permissions['use ' . $workflow
->id() . ' transition ' . $transition
->id()] = [
'title' => $this
->t('%workflow workflow: Use %transition transition.', [
'%workflow' => $workflow
->label(),
'%transition' => $transition
->label(),
]),
];
}
}
return $permissions;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Permissions:: |
public | function | Returns an array of permissions. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 4 |
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. |