1 | <?php |
||
23 | class StateMachine |
||
24 | { |
||
25 | const ON_STATE_WAS_SET = 'onStateWasSet'; |
||
26 | |||
27 | /** |
||
28 | * Schema adapter |
||
29 | * |
||
30 | * @var ProcessInterface |
||
31 | */ |
||
32 | private $process; |
||
33 | |||
34 | /** |
||
35 | * Constructor |
||
36 | * |
||
37 | * @param Process $process |
||
38 | */ |
||
39 | 4 | public function __construct(Process $process) |
|
43 | |||
44 | /** |
||
45 | * Trigger event for subject identified by identifier |
||
46 | * Restore subject from handler by its identifier, then triggers event and saves subject |
||
47 | * Return run history |
||
48 | * |
||
49 | * @param string $event |
||
50 | * @param Payload $payload |
||
51 | */ |
||
52 | 4 | public function triggerEvent($event, Payload $payload) |
|
70 | |||
71 | /** |
||
72 | * Handles onStateWasSet event |
||
73 | * Returns true if there was state change |
||
74 | * |
||
75 | * @param State $state |
||
76 | * @param Payload $payload |
||
77 | */ |
||
78 | 3 | private function handleOnStateWasSet(State $state, Payload $payload) |
|
90 | |||
91 | /** |
||
92 | * Update payload with new state data |
||
93 | * |
||
94 | * @param State $state |
||
95 | * @param Payload $payload |
||
96 | */ |
||
97 | 4 | private function updatePayload(State $state, Payload $payload) |
|
101 | } |
||
102 |