You are here

class Permissions in Workflows Field 8

Same name and namespace in other branches
  1. 2.x src/Permissions.php \Drupal\workflows_field\Permissions

Defines a class for dynamic permissions based on transitions.

@internal

Hierarchy

Expanded class hierarchy of Permissions

File

src/Permissions.php, line 13

Namespace

Drupal\workflows_field
View source
class Permissions {
  use StringTranslationTrait;

  /**
   * Returns an array of permissions.
   *
   * @return array
   *   The dynamic permissions.
   */
  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;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Permissions::getPermissions public function Returns an array of 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.