1 | <?php |
||
20 | class Interrupter implements InterrupterInterface |
||
21 | { |
||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $flowTarget; |
||
26 | |||
27 | /** |
||
28 | * @var string |
||
29 | */ |
||
30 | protected $nodeTarget; |
||
31 | |||
32 | /** |
||
33 | * interrupt type |
||
34 | * |
||
35 | * @var string |
||
36 | */ |
||
37 | protected $type; |
||
38 | |||
39 | /** |
||
40 | * @var array |
||
41 | */ |
||
42 | protected $types = [ |
||
43 | InterrupterInterface::TYPE_CONTINUE => 1, |
||
44 | InterrupterInterface::TYPE_BREAK => 1, |
||
45 | ]; |
||
46 | |||
47 | /** |
||
48 | * Interrupter constructor. |
||
49 | * |
||
50 | * @param null|string|FlowInterface $flowTarget , target up to Targeted Flow id or InterrupterInterface::TARGET_TOP to interrupt every parent |
||
51 | * @param null|string|NodeInterface $nodeTarget |
||
52 | * @param null|string $type |
||
53 | */ |
||
54 | public function __construct($flowTarget = null, $nodeTarget = null, $type = null) |
||
63 | |||
64 | /** |
||
65 | * @return string |
||
66 | */ |
||
67 | public function getType() |
||
71 | |||
72 | /** |
||
73 | * @param string $type |
||
74 | * |
||
75 | * @throws InvalidArgumentException |
||
76 | * |
||
77 | * @return $this |
||
78 | */ |
||
79 | public function setType($type) |
||
89 | |||
90 | /** |
||
91 | * Trigger the Interrupt of each ancestor Flows up to a specific one, the root one |
||
92 | * or none if : |
||
93 | * - No FlowInterrupt is set |
||
94 | * - FlowInterrupt is set at InterrupterInterface::TARGET_SELF |
||
95 | * - FlowInterrupt is set at this Flow's Id |
||
96 | * - FlowInterrupt is set as InterrupterInterface::TARGET_TOP and this has no parent |
||
97 | * |
||
98 | * Throw an exception if we reach the top after bubbling and FlowInterrupt != InterrupterInterface::TARGET_TOP |
||
99 | * |
||
100 | * @param FlowInterface $flow |
||
101 | * |
||
102 | * @throws NodalFlowException |
||
103 | * |
||
104 | * @return FlowInterface |
||
105 | */ |
||
106 | public function propagate(FlowInterface $flow) |
||
144 | |||
145 | /** |
||
146 | * @param NodeInterface|null $node |
||
147 | * |
||
148 | * @return bool |
||
149 | */ |
||
150 | public function interruptNode(NodeInterface $node = null) |
||
154 | |||
155 | /** |
||
156 | * @param FlowInterface $flow |
||
157 | * |
||
158 | * @return bool |
||
159 | */ |
||
160 | protected function isEdgeInterruptCase(FlowInterface $flow) |
||
174 | } |
||
175 |