1 | <?php |
||
2 | |||
3 | /* |
||
4 | * This file is part of NodalFlow. |
||
5 | * (c) Fabrice de Stefanis / https://github.com/fab2s/NodalFlow |
||
6 | * This source file is licensed under the MIT license which you will |
||
7 | * find in the LICENSE file or at https://opensource.org/licenses/MIT |
||
8 | */ |
||
9 | |||
10 | namespace fab2s\NodalFlow\Events; |
||
11 | |||
12 | use fab2s\NodalFlow\Flows\FlowInterface; |
||
13 | use fab2s\NodalFlow\Nodes\NodeInterface; |
||
14 | |||
15 | /** |
||
16 | * trait FlowEventProxyTrait |
||
17 | * |
||
18 | * A good example on how BC could use the S from Symfony |
||
19 | */ |
||
20 | trait FlowEventProxyTrait |
||
21 | { |
||
22 | /** |
||
23 | * @var array |
||
24 | */ |
||
25 | protected static $eventList; |
||
26 | |||
27 | /** |
||
28 | * @var FlowInterface |
||
29 | */ |
||
30 | protected $flow; |
||
31 | |||
32 | /** |
||
33 | * @var NodeInterface|null |
||
34 | */ |
||
35 | protected $node; |
||
36 | |||
37 | /** |
||
38 | * FlowEvent constructor. |
||
39 | * |
||
40 | * @param FlowInterface $flow |
||
41 | * @param NodeInterface|null $node |
||
42 | */ |
||
43 | public function __construct(FlowInterface $flow, NodeInterface $node = null) |
||
44 | { |
||
45 | $this->flow = $flow; |
||
46 | $this->node = $node; |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * @return FlowInterface |
||
51 | */ |
||
52 | public function getFlow(): FlowInterface |
||
53 | { |
||
54 | return $this->flow; |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * @return NodeInterface|null |
||
59 | */ |
||
60 | public function getNode(): ? NodeInterface |
||
61 | { |
||
62 | return $this->node; |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * @param NodeInterface|null $node |
||
67 | * |
||
68 | * @return FlowEventInterface |
||
69 | */ |
||
70 | public function setNode(NodeInterface $node = null): FlowEventInterface |
||
71 | { |
||
72 | $this->node = $node; |
||
73 | |||
74 | /* @var FlowEventInterface $this */ |
||
75 | return $this; |
||
76 | } |
||
77 | |||
78 | /** |
||
79 | * @return array |
||
80 | */ |
||
81 | public static function getEventList(): array |
||
82 | { |
||
83 | /* @var FlowEventInterface $this */ |
||
84 | if (!isset(static::$eventList)) { |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
85 | static::$eventList = [ |
||
86 | FlowEventInterface::FLOW_START => FlowEventInterface::FLOW_START, |
||
87 | FlowEventInterface::FLOW_PROGRESS => FlowEventInterface::FLOW_PROGRESS, |
||
88 | FlowEventInterface::FLOW_CONTINUE => FlowEventInterface::FLOW_CONTINUE, |
||
89 | FlowEventInterface::FLOW_BREAK => FlowEventInterface::FLOW_BREAK, |
||
90 | FlowEventInterface::FLOW_SUCCESS => FlowEventInterface::FLOW_SUCCESS, |
||
91 | FlowEventInterface::FLOW_FAIL => FlowEventInterface::FLOW_FAIL, |
||
92 | ]; |
||
93 | } |
||
94 | |||
95 | return static::$eventList; |
||
96 | } |
||
97 | } |
||
98 |