StateInterface.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace Drupal\workflows;
  3. /**
  4. * An interface for state value objects.
  5. *
  6. * @internal
  7. * The StateInterface should only be used by Workflows and Content Moderation.
  8. * @todo Revisit the need for this in https://www.drupal.org/node/2902309.
  9. */
  10. interface StateInterface {
  11. /**
  12. * The key of the state plugin form.
  13. */
  14. const PLUGIN_FORM_KEY = 'state';
  15. /**
  16. * Gets the state's ID.
  17. *
  18. * @return string
  19. * The state's ID.
  20. */
  21. public function id();
  22. /**
  23. * Gets the state's label.
  24. *
  25. * @return string
  26. * The state's label.
  27. */
  28. public function label();
  29. /**
  30. * Gets the state's weight.
  31. *
  32. * @return int
  33. * The state's weight.
  34. */
  35. public function weight();
  36. /**
  37. * Determines if the state can transition to the provided state ID.
  38. *
  39. * @param $to_state_id
  40. * The state to transition to.
  41. *
  42. * @return bool
  43. * TRUE if the state can transition to the provided state ID. FALSE, if not.
  44. */
  45. public function canTransitionTo($to_state_id);
  46. /**
  47. * Gets the Transition object for the provided state ID.
  48. *
  49. * @param $to_state_id
  50. * The state to transition to.
  51. *
  52. * @return \Drupal\workflows\TransitionInterface
  53. * The Transition object for the provided state ID.
  54. *
  55. * @throws \InvalidArgumentException()
  56. * Exception thrown when the provided state ID can not be transitioned to.
  57. */
  58. public function getTransitionTo($to_state_id);
  59. /**
  60. * Gets all the possible transition objects for the state.
  61. *
  62. * @return \Drupal\workflows\TransitionInterface[]
  63. * All the possible transition objects for the state.
  64. */
  65. public function getTransitions();
  66. }