public function Permissions::getPermissions in Workflows Field 8
Same name and namespace in other branches
- 2.x src/Permissions.php \Drupal\workflows_field\Permissions::getPermissions()
Returns an array of permissions.
Return value
array The dynamic permissions.
1 string reference to 'Permissions::getPermissions'
File
- src/
Permissions.php, line 23
Class
- Permissions
- Defines a class for dynamic permissions based on transitions.
Namespace
Drupal\workflows_fieldCode
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;
}