StateTransitionValidationInterface.php 1.5 KB

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