Update to Drupal 8.2.0. For more information, see https://www.drupal.org/project/drupal/releases/8.2.0
This commit is contained in:
parent
2f563ab520
commit
f1c8716f57
1732 changed files with 52334 additions and 11780 deletions
43
core/modules/content_moderation/src/Permissions.php
Normal file
43
core/modules/content_moderation/src/Permissions.php
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\content_moderation;
|
||||
|
||||
use Drupal\Core\StringTranslation\StringTranslationTrait;
|
||||
use Drupal\content_moderation\Entity\ModerationState;
|
||||
use Drupal\content_moderation\Entity\ModerationStateTransition;
|
||||
|
||||
/**
|
||||
* Defines a class for dynamic permissions based on transitions.
|
||||
*/
|
||||
class Permissions {
|
||||
|
||||
use StringTranslationTrait;
|
||||
|
||||
/**
|
||||
* Returns an array of transition permissions.
|
||||
*
|
||||
* @return array
|
||||
* The transition permissions.
|
||||
*/
|
||||
public function transitionPermissions() {
|
||||
// @todo https://www.drupal.org/node/2779933 write a test for this.
|
||||
$perms = [];
|
||||
/* @var \Drupal\content_moderation\ModerationStateInterface[] $states */
|
||||
$states = ModerationState::loadMultiple();
|
||||
/* @var \Drupal\content_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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in a new issue