You are here

public function Permissions::getPermissions in Workflows Field 8

Same name and namespace in other branches
  1. 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'
workflows_field.permissions.yml in ./workflows_field.permissions.yml
workflows_field.permissions.yml

File

src/Permissions.php, line 23

Class

Permissions
Defines a class for dynamic permissions based on transitions.

Namespace

Drupal\workflows_field

Code

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;
}