c793fe53e275309ae53d60557a3d1e94c7bce525
[yaffs-website] / web / core / modules / content_moderation / src / StateTransitionValidationInterface.php
1 <?php
2
3 namespace Drupal\content_moderation;
4
5 use Drupal\Core\Entity\ContentEntityInterface;
6 use Drupal\Core\Session\AccountInterface;
7 use Drupal\workflows\StateInterface;
8 use Drupal\workflows\WorkflowInterface;
9
10 /**
11  * Validates whether a certain state transition is allowed.
12  */
13 interface StateTransitionValidationInterface {
14
15   /**
16    * Gets a list of transitions that are legal for this user on this entity.
17    *
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.
22    *
23    * @return \Drupal\workflows\Transition[]
24    *   The list of transitions that are legal for this user on this entity.
25    */
26   public function getValidTransitions(ContentEntityInterface $entity, AccountInterface $user);
27
28   /**
29    * Checks if a transition between two states if valid for the given user.
30    *
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.
39    *
40    * @return bool
41    *   Returns TRUE if transition is valid, otherwise FALSE.
42    */
43   public function isTransitionValid(WorkflowInterface $workflow, StateInterface $original_state, StateInterface $new_state, AccountInterface $user);
44
45 }