3 namespace Drupal\content_moderation;
5 use Drupal\Core\Entity\ContentEntityInterface;
6 use Drupal\Core\Session\AccountInterface;
7 use Drupal\workflows\StateInterface;
8 use Drupal\workflows\WorkflowInterface;
11 * Validates whether a certain state transition is allowed.
13 interface StateTransitionValidationInterface {
16 * Gets a list of transitions that are legal for this user on this entity.
18 * @param \Drupal\Core\Entity\ContentEntityInterface $entity
19 * The entity to be transitioned.
20 * @param \Drupal\Core\Session\AccountInterface $user
21 * The account that wants to perform a transition.
23 * @return \Drupal\workflows\Transition[]
24 * The list of transitions that are legal for this user on this entity.
26 public function getValidTransitions(ContentEntityInterface $entity, AccountInterface $user);
29 * Checks if a transition between two states if valid for the given user.
31 * @param \Drupal\workflows\WorkflowInterface $workflow
32 * The workflow entity.
33 * @param \Drupal\workflows\StateInterface $original_state
34 * The original workflow state.
35 * @param \Drupal\workflows\StateInterface $new_state
36 * The new workflow state.
37 * @param \Drupal\Core\Session\AccountInterface $user
38 * The user to validate.
41 * Returns TRUE if transition is valid, otherwise FALSE.
43 public function isTransitionValid(WorkflowInterface $workflow, StateInterface $original_state, StateInterface $new_state, AccountInterface $user);