comparison core/modules/workflows/src/Transition.php @ 0:c75dbcec494b

Initial commit from drush-created site
author Chris Cannam
date Thu, 05 Jul 2018 14:24:15 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:c75dbcec494b
1 <?php
2
3 namespace Drupal\workflows;
4
5 /**
6 * A transition value object that describes the transition between states.
7 */
8 class Transition implements TransitionInterface {
9
10 /**
11 * The workflow that this transition is attached to.
12 *
13 * @var \Drupal\workflows\WorkflowInterface
14 */
15 protected $workflow;
16
17 /**
18 * The transition's ID.
19 *
20 * @var string
21 */
22 protected $id;
23
24 /**
25 * The transition's label.
26 *
27 * @var string
28 */
29 protected $label;
30
31 /**
32 * The transition's from state IDs.
33 *
34 * @var string[]
35 */
36 protected $fromStateIds;
37
38 /**
39 * The transition's to state ID.
40 *
41 * @var string
42 */
43 protected $toStateId;
44
45 /**
46 * The transition's weight.
47 *
48 * @var int
49 */
50 protected $weight;
51
52 /**
53 * Transition constructor.
54 *
55 * @param \Drupal\workflows\WorkflowInterface $workflow
56 * The workflow the state is attached to.
57 * @param string $id
58 * The transition's ID.
59 * @param string $label
60 * The transition's label.
61 * @param array $from_state_ids
62 * A list of from state IDs.
63 * @param string $to_state_id
64 * The to state ID.
65 * @param int $weight
66 * (optional) The transition's weight. Defaults to 0.
67 */
68 public function __construct(WorkflowTypeInterface $workflow, $id, $label, array $from_state_ids, $to_state_id, $weight = 0) {
69 $this->workflow = $workflow;
70 $this->id = $id;
71 $this->label = $label;
72 $this->fromStateIds = $from_state_ids;
73 $this->toStateId = $to_state_id;
74 $this->weight = $weight;
75 }
76
77 /**
78 * {@inheritdoc}
79 */
80 public function id() {
81 return $this->id;
82 }
83
84 /**
85 * {@inheritdoc}
86 */
87 public function label() {
88 return $this->label;
89 }
90
91 /**
92 * {@inheritdoc}
93 */
94 public function from() {
95 return $this->workflow->getStates($this->fromStateIds);
96 }
97
98 /**
99 * {@inheritdoc}
100 */
101 public function to() {
102 return $this->workflow->getState($this->toStateId);
103 }
104
105 /**
106 * {@inheritdoc}
107 */
108 public function weight() {
109 return $this->weight;
110 }
111
112 }