1 | <?php |
||
31 | abstract class AbstractTransitionHandler implements TransitionHandler |
||
32 | { |
||
33 | /** |
||
34 | * The given entity. |
||
35 | * |
||
36 | * @var Item |
||
37 | */ |
||
38 | private $item; |
||
39 | |||
40 | /** |
||
41 | * The current workflow. |
||
42 | * |
||
43 | * @var Workflow |
||
44 | */ |
||
45 | private $workflow; |
||
46 | |||
47 | /** |
||
48 | * The transition name which will be handled. |
||
49 | * |
||
50 | * @var string |
||
51 | */ |
||
52 | private $transitionName; |
||
53 | |||
54 | /** |
||
55 | * Validation state. |
||
56 | * |
||
57 | * @var bool |
||
58 | */ |
||
59 | private $validated; |
||
60 | |||
61 | /** |
||
62 | * The transaction handler. |
||
63 | * |
||
64 | * @var TransactionHandler |
||
65 | */ |
||
66 | protected $transactionHandler; |
||
67 | |||
68 | /** |
||
69 | * The transition context. |
||
70 | * |
||
71 | * @var Context |
||
72 | */ |
||
73 | private $context; |
||
74 | |||
75 | /** |
||
76 | * Construct. |
||
77 | * |
||
78 | * @param Item $item The item. |
||
79 | * @param Workflow $workflow The current workflow. |
||
80 | * @param string $transitionName The transition to be handled. |
||
81 | * @param TransactionHandler $transactionHandler TransactionHandler take care of transactions. |
||
82 | * |
||
83 | * @throws FlowException If invalid transition name is given. |
||
84 | */ |
||
85 | public function __construct( |
||
99 | |||
100 | /** |
||
101 | * {@inheritdoc} |
||
102 | */ |
||
103 | public function getTransition(): Transition |
||
111 | |||
112 | /** |
||
113 | * {@inheritdoc} |
||
114 | */ |
||
115 | public function getWorkflow(): Workflow |
||
119 | |||
120 | /** |
||
121 | * {@inheritdoc} |
||
122 | */ |
||
123 | public function getItem(): Item |
||
127 | |||
128 | /** |
||
129 | * {@inheritdoc} |
||
130 | */ |
||
131 | public function getContext(): Context |
||
135 | |||
136 | /** |
||
137 | * {@inheritdoc} |
||
138 | */ |
||
139 | public function isWorkflowStarted(): bool |
||
143 | |||
144 | /** |
||
145 | * {@inheritdoc} |
||
146 | */ |
||
147 | public function getRequiredPayloadProperties(): array |
||
151 | |||
152 | /** |
||
153 | * Consider if transition is available. |
||
154 | * |
||
155 | * @return bool |
||
156 | */ |
||
157 | public function isAvailable(): bool |
||
161 | |||
162 | /** |
||
163 | * {@inheritdoc} |
||
164 | */ |
||
165 | public function getCurrentStep():? Step |
||
175 | |||
176 | /** |
||
177 | * {@inheritdoc} |
||
178 | */ |
||
179 | public function validate(array $payload = []): bool |
||
202 | |||
203 | /** |
||
204 | * Execute the transition. |
||
205 | * |
||
206 | * @return State |
||
207 | */ |
||
208 | protected function executeTransition(): State |
||
223 | |||
224 | /** |
||
225 | * Guard that transition was validated before. |
||
226 | * |
||
227 | * @throws FlowException If transition. |
||
228 | * |
||
229 | * @return void |
||
230 | */ |
||
231 | protected function guardValidated(): void |
||
239 | |||
240 | /** |
||
241 | * Guard that requested transition is allowed. |
||
242 | * |
||
243 | * @param string|null $transitionName Transition to be processed. |
||
244 | * |
||
245 | * @throws FlowException If Transition is not allowed. |
||
246 | * |
||
247 | * @return void |
||
248 | */ |
||
249 | private function guardAllowedTransition(?string $transitionName): void |
||
278 | } |
||
279 |