summaryrefslogtreecommitdiffstatshomepage
path: root/core/modules/workflows/src/StateInterface.php
blob: 5ae57da528b37622233c122ad2a4509b26be784f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php

namespace Drupal\workflows;

/**
 * An interface for state value objects.
 *
 * @internal
 *   The StateInterface should only be used by Workflows and Content Moderation.
 * @todo Revisit the need for this in https://www.drupal.org/node/2902309.
 */
interface StateInterface {

  /**
   * The key of the state plugin form.
   */
  const PLUGIN_FORM_KEY = 'state';

  /**
   * Gets the state's ID.
   *
   * @return string
   *   The state's ID.
   */
  public function id();

  /**
   * Gets the state's label.
   *
   * @return string
   *   The state's label.
   */
  public function label();

  /**
   * Gets the state's weight.
   *
   * @return int
   *   The state's weight.
   */
  public function weight();

  /**
   * Determines if the state can transition to the provided state ID.
   *
   * @param string $to_state_id
   *   The state to transition to.
   *
   * @return bool
   *   TRUE if the state can transition to the provided state ID. FALSE, if not.
   */
  public function canTransitionTo($to_state_id);

  /**
   * Gets the Transition object for the provided state ID.
   *
   * @param string $to_state_id
   *   The state to transition to.
   *
   * @return \Drupal\workflows\TransitionInterface
   *   The Transition object for the provided state ID.
   *
   * @throws \InvalidArgumentException
   *   Exception thrown when the provided state ID can not be transitioned to.
   */
  public function getTransitionTo($to_state_id);

  /**
   * Gets all the possible transition objects for the state.
   *
   * @return \Drupal\workflows\TransitionInterface[]
   *   All the possible transition objects for the state.
   */
  public function getTransitions();

}