|
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
|
|
|
use Symfony\Component\EventDispatcher\Event; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Class FlowEvent |
|
18
|
|
|
*/ |
|
19
|
|
|
class FlowEvent extends Event implements FlowEventInterface |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* Flow Events |
|
23
|
|
|
*/ |
|
24
|
|
|
const FLOW_START = 'flow.start'; |
|
25
|
|
|
const FLOW_PROGRESS = 'flow.progress'; |
|
26
|
|
|
const FLOW_CONTINUE = 'flow.continue'; |
|
27
|
|
|
const FLOW_BREAK = 'flow.break'; |
|
28
|
|
|
const FLOW_SUCCESS = 'flow.success'; |
|
29
|
|
|
const FLOW_FAIL = 'flow.fail'; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @var array |
|
33
|
|
|
*/ |
|
34
|
|
|
protected static $eventList; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @var FlowInterface |
|
38
|
|
|
*/ |
|
39
|
|
|
protected $flow; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @var NodeInterface|null |
|
43
|
|
|
*/ |
|
44
|
|
|
protected $node; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* FlowEvent constructor. |
|
48
|
|
|
* |
|
49
|
|
|
* @param FlowInterface $flow |
|
50
|
|
|
* @param NodeInterface|null $node |
|
51
|
|
|
*/ |
|
52
|
|
|
public function __construct(FlowInterface $flow, NodeInterface $node = null) |
|
53
|
|
|
{ |
|
54
|
|
|
$this->flow = $flow; |
|
55
|
|
|
$this->node = $node; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @return FlowInterface |
|
60
|
|
|
*/ |
|
61
|
|
|
public function getFlow() |
|
62
|
|
|
{ |
|
63
|
|
|
return $this->flow; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @return NodeInterface |
|
68
|
|
|
*/ |
|
69
|
|
|
public function getNode() |
|
70
|
|
|
{ |
|
71
|
|
|
return $this->node; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @param NodeInterface|null $node |
|
76
|
|
|
* |
|
77
|
|
|
* @return $this |
|
78
|
|
|
*/ |
|
79
|
|
|
public function setNode(NodeInterface $node = null) |
|
80
|
|
|
{ |
|
81
|
|
|
$this->node = $node; |
|
82
|
|
|
|
|
83
|
|
|
return $this; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* @return array |
|
88
|
|
|
*/ |
|
89
|
|
|
public static function getEventList() |
|
90
|
|
|
{ |
|
91
|
|
|
if (!isset(static::$eventList)) { |
|
92
|
|
|
static::$eventList = [ |
|
93
|
|
|
static::FLOW_START => static::FLOW_START, |
|
94
|
|
|
static::FLOW_PROGRESS => static::FLOW_PROGRESS, |
|
95
|
|
|
static::FLOW_CONTINUE => static::FLOW_CONTINUE, |
|
96
|
|
|
static::FLOW_BREAK => static::FLOW_BREAK, |
|
97
|
|
|
static::FLOW_SUCCESS => static::FLOW_SUCCESS, |
|
98
|
|
|
static::FLOW_FAIL => static::FLOW_FAIL, |
|
99
|
|
|
]; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
return static::$eventList; |
|
103
|
|
|
} |
|
104
|
|
|
} |
|
105
|
|
|
|