1 | <?php |
||
32 | abstract class AbstractTransitionHandler implements TransitionHandler |
||
33 | { |
||
34 | /** |
||
35 | * The given entity. |
||
36 | * |
||
37 | * @var Item |
||
38 | */ |
||
39 | private $item; |
||
40 | |||
41 | /** |
||
42 | * The current workflow. |
||
43 | * |
||
44 | * @var Workflow |
||
45 | */ |
||
46 | private $workflow; |
||
47 | |||
48 | /** |
||
49 | * The transition name which will be handled. |
||
50 | * |
||
51 | * @var string |
||
52 | */ |
||
53 | private $transitionName; |
||
54 | |||
55 | /** |
||
56 | * Validation state. |
||
57 | * |
||
58 | * @var bool |
||
59 | */ |
||
60 | private $validated; |
||
61 | |||
62 | /** |
||
63 | * The transaction handler. |
||
64 | * |
||
65 | * @var TransactionHandler |
||
66 | */ |
||
67 | protected $transactionHandler; |
||
68 | |||
69 | /** |
||
70 | * The transition context. |
||
71 | * |
||
72 | * @var Context |
||
73 | */ |
||
74 | private $context; |
||
75 | |||
76 | /** |
||
77 | * Error collection of errors occurred during transition handling. |
||
78 | * |
||
79 | * @var ErrorCollection |
||
80 | */ |
||
81 | private $errorCollection; |
||
82 | |||
83 | /** |
||
84 | * Construct. |
||
85 | * |
||
86 | * @param Item $item The item. |
||
87 | * @param Workflow $workflow The current workflow. |
||
88 | * @param string $transitionName The transition to be handled. |
||
89 | * @param TransactionHandler $transactionHandler TransactionHandler take care of transactions. |
||
90 | * |
||
91 | * @throws WorkflowException If invalid transition name is given. |
||
92 | */ |
||
93 | public function __construct( |
||
108 | |||
109 | /** |
||
110 | * {@inheritdoc} |
||
111 | */ |
||
112 | public function getTransition(): Transition |
||
120 | |||
121 | /** |
||
122 | * {@inheritdoc} |
||
123 | */ |
||
124 | public function getWorkflow(): Workflow |
||
128 | |||
129 | /** |
||
130 | * {@inheritdoc} |
||
131 | */ |
||
132 | public function getItem(): Item |
||
136 | |||
137 | /** |
||
138 | * {@inheritdoc} |
||
139 | */ |
||
140 | public function getContext(): Context |
||
144 | |||
145 | /** |
||
146 | * {@inheritdoc} |
||
147 | */ |
||
148 | public function isWorkflowStarted(): bool |
||
152 | |||
153 | /** |
||
154 | * {@inheritdoc} |
||
155 | */ |
||
156 | public function getRequiredPayloadProperties(): array |
||
160 | |||
161 | /** |
||
162 | * Consider if transition is available. |
||
163 | * |
||
164 | * @return bool |
||
165 | */ |
||
166 | public function isAvailable(): bool |
||
170 | |||
171 | /** |
||
172 | * {@inheritdoc} |
||
173 | */ |
||
174 | public function getErrorCollection(): ErrorCollection |
||
178 | |||
179 | /** |
||
180 | * {@inheritdoc} |
||
181 | */ |
||
182 | public function getCurrentStep():? Step |
||
192 | |||
193 | /** |
||
194 | * {@inheritdoc} |
||
195 | */ |
||
196 | public function validate(array $payload): bool |
||
216 | |||
217 | /** |
||
218 | * Execute the transition. |
||
219 | * |
||
220 | * @return State |
||
221 | */ |
||
222 | protected function executeTransition(): State |
||
237 | |||
238 | /** |
||
239 | * Guard that transition was validated before. |
||
240 | * |
||
241 | * @throws WorkflowException If transition. |
||
242 | * |
||
243 | * @return void |
||
244 | */ |
||
245 | protected function guardValidated(): void |
||
253 | |||
254 | /** |
||
255 | * Guard that requested transition is allowed. |
||
256 | * |
||
257 | * @param string $transitionName Transition to be processed. |
||
258 | * |
||
259 | * @throws WorkflowException If Transition is not allowed. |
||
260 | * |
||
261 | * @return void |
||
262 | */ |
||
263 | private function guardAllowedTransition(string $transitionName): void |
||
292 | } |
||
293 |