You are here

class Permissions in Drupal 8

Same name in this branch
  1. 8 core/modules/content_moderation/src/Permissions.php \Drupal\content_moderation\Permissions
  2. 8 core/modules/user/src/Plugin/views/filter/Permissions.php \Drupal\user\Plugin\views\filter\Permissions
  3. 8 core/modules/user/src/Plugin/views/field/Permissions.php \Drupal\user\Plugin\views\field\Permissions
Same name and namespace in other branches
  1. 9 core/modules/content_moderation/src/Permissions.php \Drupal\content_moderation\Permissions

Defines a class for dynamic permissions based on transitions.

@internal

Hierarchy

Expanded class hierarchy of Permissions

1 file declares its use of Permissions
ContentModerationPermissionsTest.php in core/modules/content_moderation/tests/src/Kernel/ContentModerationPermissionsTest.php
4 string references to 'Permissions'
ModulesListForm::buildRow in core/modules/system/src/Form/ModulesListForm.php
Builds a table row for the system modules page.
user.links.task.yml in core/modules/user/user.links.task.yml
core/modules/user/user.links.task.yml
user.routing.yml in core/modules/user/user.routing.yml
core/modules/user/user.routing.yml
user.schema.yml in core/modules/user/config/schema/user.schema.yml
core/modules/user/config/schema/user.schema.yml

File

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

Namespace

Drupal\content_moderation
View source
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;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Permissions::transitionPermissions public function Returns an array of transition permissions.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.