function Permissions::transitionPermissions
Same name in other branches
- 9 core/modules/content_moderation/src/Permissions.php \Drupal\content_moderation\Permissions::transitionPermissions()
- 8.9.x core/modules/content_moderation/src/Permissions.php \Drupal\content_moderation\Permissions::transitionPermissions()
- 11.x core/modules/content_moderation/src/Permissions.php \Drupal\content_moderation\Permissions::transitionPermissions()
Returns an array of transition permissions.
Return value
array The transition permissions.
1 string reference to 'Permissions::transitionPermissions'
- content_moderation.permissions.yml in core/
modules/ content_moderation/ content_moderation.permissions.yml - core/modules/content_moderation/content_moderation.permissions.yml
File
-
core/
modules/ content_moderation/ src/ Permissions.php, line 24
Class
- Permissions
- Defines a class for dynamic permissions based on transitions.
Namespace
Drupal\content_moderationCode
public function transitionPermissions() {
$permissions = [];
/** @var \Drupal\workflows\WorkflowInterface $workflow */
foreach (Workflow::loadMultipleByType('content_moderation') as $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(),
]),
'description' => $this->formatPlural(count($transition->from()), 'Move content from %from state to %to state.', 'Move content from %from states to %to state.', [
'%from' => implode(', ', array_map([
State::class,
'labelCallback',
], $transition->from())),
'%to' => $transition->to()
->label(),
]),
'dependencies' => [
$workflow->getConfigDependencyKey() => [
$workflow->getConfigDependencyName(),
],
],
];
}
}
return $permissions;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.