comparison core/modules/content_moderation/src/StateTransitionValidation.php @ 4:a9cd425dd02b

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:11:55 +0000
parents c75dbcec494b
children
comparison
equal deleted inserted replaced
3:307d7a7fd348 4:a9cd425dd02b
2 2
3 namespace Drupal\content_moderation; 3 namespace Drupal\content_moderation;
4 4
5 use Drupal\Core\Entity\ContentEntityInterface; 5 use Drupal\Core\Entity\ContentEntityInterface;
6 use Drupal\Core\Session\AccountInterface; 6 use Drupal\Core\Session\AccountInterface;
7 use Drupal\workflows\StateInterface;
7 use Drupal\workflows\Transition; 8 use Drupal\workflows\Transition;
9 use Drupal\workflows\WorkflowInterface;
8 10
9 /** 11 /**
10 * Validates whether a certain state transition is allowed. 12 * Validates whether a certain state transition is allowed.
11 */ 13 */
12 class StateTransitionValidation implements StateTransitionValidationInterface { 14 class StateTransitionValidation implements StateTransitionValidationInterface {
45 return array_filter($current_state->getTransitions(), function (Transition $transition) use ($workflow, $user) { 47 return array_filter($current_state->getTransitions(), function (Transition $transition) use ($workflow, $user) {
46 return $user->hasPermission('use ' . $workflow->id() . ' transition ' . $transition->id()); 48 return $user->hasPermission('use ' . $workflow->id() . ' transition ' . $transition->id());
47 }); 49 });
48 } 50 }
49 51
52 /**
53 * {@inheritdoc}
54 */
55 public function isTransitionValid(WorkflowInterface $workflow, StateInterface $original_state, StateInterface $new_state, AccountInterface $user, ContentEntityInterface $entity = NULL) {
56 if ($entity === NULL) {
57 @trigger_error(sprintf('Omitting the $entity parameter from %s is deprecated and will be required in Drupal 9.0.0.', __METHOD__), E_USER_DEPRECATED);
58 }
59 $transition = $workflow->getTypePlugin()->getTransitionFromStateToState($original_state->id(), $new_state->id());
60 return $user->hasPermission('use ' . $workflow->id() . ' transition ' . $transition->id());
61 }
62
50 } 63 }