class Permissions in Workbench Moderation 8
Same name and namespace in other branches
- 8.2 src/Permissions.php \Drupal\workbench_moderation\Permissions
Defines a class for dynamic permissions based on transitions.
Hierarchy
- class \Drupal\workbench_moderation\Permissions uses StringTranslationTrait
Expanded class hierarchy of Permissions
File
- src/
Permissions.php, line 12
Namespace
Drupal\workbench_moderationView source
class Permissions {
use StringTranslationTrait;
/**
* Returns an array of transition permissions.
*
* @return array
* The transition permissions.
*/
public function transitionPermissions() {
// @todo write a test for this.
$perms = [];
/* @var \Drupal\workbench_moderation\ModerationStateInterface[] $states */
$states = ModerationState::loadMultiple();
/* @var \Drupal\workbench_moderation\ModerationStateTransitionInterface $transition */
foreach (ModerationStateTransition::loadMultiple() as $id => $transition) {
$perms['use ' . $id . ' transition'] = [
'title' => $this
->t('Use the %transition_name transition', [
'%transition_name' => $transition
->label(),
]),
'description' => $this
->t('Move content from %from state to %to state.', [
'%from' => $states[$transition
->getFromState()]
->label(),
'%to' => $states[$transition
->getToState()]
->label(),
]),
];
}
return $perms;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Permissions:: |
public | function | Returns an array of transition permissions. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |