class Permissions in Drupal 10
Same name in this branch
- 10 core/modules/content_moderation/src/Permissions.php \Drupal\content_moderation\Permissions
- 10 core/modules/user/src/Plugin/views/filter/Permissions.php \Drupal\user\Plugin\views\filter\Permissions
- 10 core/modules/user/src/Plugin/views/field/Permissions.php \Drupal\user\Plugin\views\field\Permissions
Same name and namespace in other branches
- 8 core/modules/content_moderation/src/Permissions.php \Drupal\content_moderation\Permissions
- 9 core/modules/content_moderation/src/Permissions.php \Drupal\content_moderation\Permissions
Defines a class for dynamic permissions based on transitions.
@internal
Hierarchy
- class \Drupal\content_moderation\Permissions uses StringTranslationTrait
Expanded class hierarchy of Permissions
1 file declares its use of Permissions
- ContentModerationPermissionsTest.php in core/
modules/ content_moderation/ tests/ src/ Kernel/ ContentModerationPermissionsTest.php
7 string references to 'Permissions'
- drupal6.php in core/
modules/ migrate_drupal/ tests/ fixtures/ drupal6.php - A database agnostic dump for testing purposes.
- drupal7.php in core/
modules/ tracker/ tests/ fixtures/ drupal7.php - A database agnostic dump for testing purposes.
- drupal7.php in core/
modules/ rdf/ tests/ fixtures/ drupal7.php - A database agnostic dump for testing purposes.
- drupal7.php in core/
modules/ migrate_drupal/ tests/ fixtures/ drupal7.php - A database agnostic dump for testing purposes.
- user.links.task.yml in core/
modules/ user/ user.links.task.yml - core/modules/user/user.links.task.yml
File
- core/
modules/ content_moderation/ src/ Permissions.php, line 14
Namespace
Drupal\content_moderationView source
class Permissions {
use StringTranslationTrait;
/**
* Returns an array of transition permissions.
*
* @return array
* The transition permissions.
*/
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;
}
}