Permissions.php

Same filename in this branch
  1. 8.9.x core/modules/user/src/Plugin/views/field/Permissions.php
  2. 8.9.x core/modules/user/src/Plugin/views/filter/Permissions.php
Same filename in other branches
  1. 9 core/modules/content_moderation/src/Permissions.php
  2. 9 core/modules/user/src/Plugin/views/field/Permissions.php
  3. 9 core/modules/user/src/Plugin/views/filter/Permissions.php
  4. 10 core/modules/content_moderation/src/Permissions.php
  5. 10 core/modules/user/src/Plugin/views/field/Permissions.php
  6. 10 core/modules/user/src/Plugin/views/filter/Permissions.php
  7. 11.x core/modules/content_moderation/src/Permissions.php
  8. 11.x core/modules/user/src/Plugin/views/field/Permissions.php
  9. 11.x core/modules/user/src/Plugin/views/filter/Permissions.php

Namespace

Drupal\content_moderation

File

core/modules/content_moderation/src/Permissions.php

View source
<?php

namespace Drupal\content_moderation;

use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\workflows\Entity\Workflow;

/**
 * Defines a class for dynamic permissions based on transitions.
 *
 * @internal
 */
class Permissions {
    use StringTranslationTrait;
    
    /**
     * Returns an array of transition permissions.
     *
     * @return array
     *   The transition permissions.
     */
    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;
    }

}

Classes

Title Deprecated Summary
Permissions Defines a class for dynamic permissions based on transitions.

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