function Permissions::transitionPermissions

Same name in other branches
  1. 9 core/modules/content_moderation/src/Permissions.php \Drupal\content_moderation\Permissions::transitionPermissions()
  2. 10 core/modules/content_moderation/src/Permissions.php \Drupal\content_moderation\Permissions::transitionPermissions()
  3. 11.x core/modules/content_moderation/src/Permissions.php \Drupal\content_moderation\Permissions::transitionPermissions()

Returns an array of transition permissions.

Return value

array The transition permissions.

1 string reference to 'Permissions::transitionPermissions'
content_moderation.permissions.yml in core/modules/content_moderation/content_moderation.permissions.yml
core/modules/content_moderation/content_moderation.permissions.yml

File

core/modules/content_moderation/src/Permissions.php, line 23

Class

Permissions
Defines a class for dynamic permissions based on transitions.

Namespace

Drupal\content_moderation

Code

public function transitionPermissions() {
    $permissions = [];
    
    /** @var \Drupal\workflows\WorkflowInterface $workflow */
    foreach (Workflow::loadMultipleByType('content_moderation') 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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.