You are here

class Permissions in Workbench Moderation State Access 8

Defines a class for dynamic permissions based on states.

Hierarchy

Expanded class hierarchy of Permissions

File

src/Permissions.php, line 11

Namespace

Drupal\workbench_moderation_state_access
View source
class Permissions {
  use StringTranslationTrait;

  /**
   * Returns an array of edit permissions.
   *
   * @return array
   *   The edit permissions.
   */
  public function editPermissions() {

    // @todo write a test for this.
    $perms = [];

    /* @var \Drupal\workbench_moderation\ModerationStateInterface $state */
    foreach (ModerationState::loadMultiple() as $id => $state) {
      $perms['edit content in the ' . $id . ' state'] = [
        'title' => $this
          ->t('Edit content when in the %state_name state.', [
          '%state_name' => $state
            ->label(),
        ]),
      ];
    }
    return $perms;
  }

}

Members

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