View source
<?php
namespace Drupal\workbench_moderation;
use Drupal\Core\Routing\UrlGeneratorTrait;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\workbench_moderation\Entity\ModerationState;
use Drupal\workbench_moderation\Entity\ModerationStateTransition;
class Permissions {
use StringTranslationTrait;
use UrlGeneratorTrait;
public function transitionPermissions() {
$perms = [];
$states = ModerationState::loadMultiple();
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;
}
}