Permissions.php in Workflows Field 2.x
File
src/Permissions.php
View source
<?php
namespace Drupal\workflows_field;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\workflows\Entity\Workflow;
class Permissions {
use StringTranslationTrait;
public function getPermissions() {
$permissions = [];
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;
}
}
Classes
Name |
Description |
Permissions |
Defines a class for dynamic permissions based on transitions. |