1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Darkilliant\ProcessBundle\ProcessNotifier; |
4
|
|
|
|
5
|
|
|
use Darkilliant\ProcessBundle\State\ProcessState; |
6
|
|
|
use Darkilliant\ProcessBundle\Step\StepInterface; |
7
|
|
|
|
8
|
|
|
class ChainProcessNotifier implements ProcessNotifierInterface |
9
|
|
|
{ |
10
|
|
|
/** @var ProcessNotifierInterface[] */ |
11
|
|
|
private $notifiers = []; |
12
|
|
|
|
13
|
9 |
|
public function add(ProcessNotifierInterface $notifier) |
14
|
|
|
{ |
15
|
9 |
|
$this->notifiers[] = $notifier; |
16
|
9 |
|
} |
17
|
|
|
|
18
|
1 |
|
public function onExecutedProcess(ProcessState $state, StepInterface $step) |
19
|
|
|
{ |
20
|
1 |
|
foreach ($this->notifiers as $notifier) { |
21
|
1 |
|
$notifier->onExecutedProcess($state, $step); |
22
|
|
|
} |
23
|
1 |
|
} |
24
|
|
|
|
25
|
1 |
|
public function onStartProcess(ProcessState $state, StepInterface $step) |
26
|
|
|
{ |
27
|
1 |
|
foreach ($this->notifiers as $notifier) { |
28
|
1 |
|
$notifier->onStartProcess($state, $step); |
29
|
|
|
} |
30
|
1 |
|
} |
31
|
|
|
|
32
|
1 |
|
public function onEndProcess(ProcessState $state, StepInterface $step) |
33
|
|
|
{ |
34
|
1 |
|
foreach ($this->notifiers as $notifier) { |
35
|
1 |
|
$notifier->onEndProcess($state, $step); |
36
|
|
|
} |
37
|
1 |
|
} |
38
|
|
|
|
39
|
1 |
|
public function onStartIterableProcess(ProcessState $state, StepInterface $step) |
40
|
|
|
{ |
41
|
1 |
|
foreach ($this->notifiers as $notifier) { |
42
|
1 |
|
$notifier->onStartIterableProcess($state, $step); |
43
|
|
|
} |
44
|
1 |
|
} |
45
|
|
|
|
46
|
1 |
|
public function onUpdateIterableProcess(ProcessState $state, StepInterface $step) |
47
|
|
|
{ |
48
|
1 |
|
foreach ($this->notifiers as $notifier) { |
49
|
1 |
|
$notifier->onUpdateIterableProcess($state, $step); |
50
|
|
|
} |
51
|
1 |
|
} |
52
|
|
|
|
53
|
1 |
|
public function onSuccessLoop(ProcessState $state, StepInterface $step) |
54
|
|
|
{ |
55
|
1 |
|
foreach ($this->notifiers as $notifier) { |
56
|
1 |
|
$notifier->onSuccessLoop($state, $step); |
57
|
|
|
} |
58
|
1 |
|
} |
59
|
|
|
|
60
|
1 |
|
public function onFailedLoop(ProcessState $state, StepInterface $step) |
61
|
|
|
{ |
62
|
1 |
|
foreach ($this->notifiers as $notifier) { |
63
|
1 |
|
$notifier->onFailedLoop($state, $step); |
64
|
|
|
} |
65
|
1 |
|
} |
66
|
|
|
|
67
|
1 |
|
public function onStartRunner(ProcessState $state) |
68
|
|
|
{ |
69
|
1 |
|
foreach ($this->notifiers as $notifier) { |
70
|
1 |
|
$notifier->onStartRunner($state); |
71
|
|
|
} |
72
|
1 |
|
} |
73
|
|
|
|
74
|
1 |
|
public function onEndRunner(ProcessState $state, bool $successfull) |
75
|
|
|
{ |
76
|
1 |
|
foreach ($this->notifiers as $notifier) { |
77
|
1 |
|
$notifier->onEndRunner($state, $successfull); |
78
|
|
|
} |
79
|
1 |
|
} |
80
|
|
|
} |
81
|
|
|
|