1 | <?php |
||
18 | abstract class FlowAbstract implements FlowInterface |
||
19 | { |
||
20 | use FlowIdTrait; |
||
21 | |||
22 | /** |
||
23 | * The parent Flow, only set when branched |
||
24 | * |
||
25 | * @var FlowInterface |
||
26 | */ |
||
27 | public $parent; |
||
28 | |||
29 | /** |
||
30 | * Current Flow Status |
||
31 | * |
||
32 | * @var FlowStatusInterface |
||
33 | */ |
||
34 | protected $flowStatus; |
||
35 | |||
36 | /** |
||
37 | * The underlying node structure |
||
38 | * |
||
39 | * @var NodeInterface[] |
||
40 | */ |
||
41 | protected $nodes = []; |
||
42 | |||
43 | /** |
||
44 | * @var FlowMapInterface |
||
45 | */ |
||
46 | protected $flowMap; |
||
47 | |||
48 | /** |
||
49 | * Continue flag |
||
50 | * |
||
51 | * @var bool |
||
52 | */ |
||
53 | protected $continue = false; |
||
54 | |||
55 | /** |
||
56 | * Break Flag |
||
57 | * |
||
58 | * @var bool |
||
59 | */ |
||
60 | protected $break = false; |
||
61 | |||
62 | /** |
||
63 | * Progress modulo to apply |
||
64 | * Set to x if you want to trigger |
||
65 | * progress every x iterations in flow |
||
66 | * |
||
67 | * @var int |
||
68 | */ |
||
69 | protected $progressMod = 1024; |
||
70 | |||
71 | /** |
||
72 | * @var string|bool |
||
73 | */ |
||
74 | protected $interruptNodeId; |
||
75 | |||
76 | /** |
||
77 | * Get the stats array with latest Node stats |
||
78 | * |
||
79 | * @return array |
||
80 | */ |
||
81 | public function getStats() |
||
85 | |||
86 | /** |
||
87 | * Get the stats array with latest Node stats |
||
88 | * |
||
89 | * @return FlowMapInterface |
||
90 | */ |
||
91 | public function getFlowMap() |
||
95 | |||
96 | /** |
||
97 | * Get the Node array |
||
98 | * |
||
99 | * @return NodeInterface[] |
||
100 | */ |
||
101 | public function getNodes() |
||
105 | |||
106 | /** |
||
107 | * Get/Generate Node Map |
||
108 | * |
||
109 | * @return array |
||
110 | */ |
||
111 | public function getNodeMap() |
||
115 | |||
116 | /** |
||
117 | * Get current $progressMod |
||
118 | * |
||
119 | * @return int |
||
120 | */ |
||
121 | public function getProgressMod() |
||
125 | |||
126 | /** |
||
127 | * The Flow status can either indicate be: |
||
128 | * - clean (isClean()): everything went well |
||
129 | * - dirty (isDirty()): one Node broke the flow |
||
130 | * - exception (isException()): an exception was raised during the flow |
||
131 | * |
||
132 | * @return FlowStatusInterface |
||
133 | */ |
||
134 | public function getFlowStatus() |
||
138 | |||
139 | /** |
||
140 | * getId() alias for backward compatibility |
||
141 | * |
||
142 | * @deprecated use `getId` instead |
||
143 | * |
||
144 | * @return string |
||
145 | */ |
||
146 | public function getFlowId() |
||
150 | |||
151 | /** |
||
152 | * Set parent Flow, happens only when branched |
||
153 | * |
||
154 | * @param FlowInterface $flow |
||
155 | * |
||
156 | * @return $this |
||
157 | */ |
||
158 | public function setParent(FlowInterface $flow) |
||
164 | |||
165 | /** |
||
166 | * Get eventual parent Flow |
||
167 | * |
||
168 | * @return FlowInterface |
||
169 | */ |
||
170 | public function getParent() |
||
174 | |||
175 | /** |
||
176 | * Tells if this flow has a parent |
||
177 | * |
||
178 | * @return bool |
||
179 | */ |
||
180 | public function hasParent() |
||
184 | |||
185 | /** |
||
186 | * Define the progress modulo, Progress Callback will be |
||
187 | * triggered upon each iteration in the flow modulo $progressMod |
||
188 | * |
||
189 | * @param int $progressMod |
||
190 | * |
||
191 | * @return $this |
||
192 | */ |
||
193 | public function setProgressMod($progressMod) |
||
199 | |||
200 | /** |
||
201 | * @param string $interruptType |
||
202 | * @param InterrupterInterface|null $flowInterrupt |
||
203 | * |
||
204 | * @throws NodalFlowException |
||
205 | * |
||
206 | * @return $this |
||
207 | */ |
||
208 | public function interruptFlow($interruptType, InterrupterInterface $flowInterrupt = null) |
||
230 | |||
231 | /** |
||
232 | * Used to set the eventual Node Target of an Interrupt signal |
||
233 | * set to : |
||
234 | * - A node hash to target |
||
235 | * - true to interrupt every upstream nodes |
||
236 | * in this Flow |
||
237 | * - false to only interrupt up to the first |
||
238 | * upstream Traversable in this Flow |
||
239 | * |
||
240 | * @param string|bool $interruptNodeId |
||
241 | * |
||
242 | * @return $this |
||
243 | */ |
||
244 | public function setInterruptNodeId($interruptNodeId) |
||
250 | |||
251 | /** |
||
252 | * @param NodeInterface $node |
||
253 | * |
||
254 | * @return bool |
||
255 | */ |
||
256 | protected function interruptNode(NodeInterface $node) |
||
262 | } |
||
263 |