1 | <?php |
||
2 | |||
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
3 | namespace Jaxon\App\Config; |
||
4 | |||
5 | /** |
||
0 ignored issues
–
show
|
|||
6 | * ConfigEventManager.php |
||
7 | * |
||
8 | * Call listeners on config changes. |
||
9 | * |
||
10 | * @package jaxon-core |
||
11 | * @author Thierry Feuzeu <[email protected]> |
||
12 | * @copyright 2022 Thierry Feuzeu <[email protected]> |
||
13 | * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License |
||
14 | * @link https://github.com/jaxon-php/jaxon-core |
||
15 | */ |
||
16 | |||
17 | use Jaxon\Di\Container; |
||
18 | use Jaxon\Utils\Config\Config; |
||
19 | |||
20 | class ConfigEventManager implements ConfigListenerInterface |
||
0 ignored issues
–
show
|
|||
21 | { |
||
22 | /** |
||
23 | * @var Container |
||
24 | */ |
||
25 | protected $di; |
||
0 ignored issues
–
show
|
|||
26 | |||
27 | /** |
||
28 | * @var string[] |
||
29 | */ |
||
30 | protected $aListeners = []; |
||
31 | |||
32 | /** |
||
33 | * The constructor |
||
34 | * |
||
35 | * @param Container $di |
||
0 ignored issues
–
show
|
|||
36 | */ |
||
37 | public function __construct(Container $di) |
||
0 ignored issues
–
show
|
|||
38 | { |
||
39 | $this->di = $di; |
||
40 | } |
||
0 ignored issues
–
show
|
|||
41 | |||
42 | /** |
||
43 | * Add a listener |
||
44 | * |
||
45 | * @param string $sClassName |
||
0 ignored issues
–
show
|
|||
46 | * |
||
47 | * @return void |
||
48 | */ |
||
49 | public function addListener(string $sClassName) |
||
50 | { |
||
51 | $this->aListeners[] = $sClassName; |
||
52 | } |
||
0 ignored issues
–
show
|
|||
53 | |||
54 | /** |
||
0 ignored issues
–
show
|
|||
55 | * @inheritDoc |
||
56 | */ |
||
0 ignored issues
–
show
|
|||
57 | public function onChange(Config $xConfig, string $sName) |
||
58 | { |
||
59 | foreach($this->aListeners as $sListener) |
||
60 | { |
||
61 | $this->di->g($sListener)->onChange($xConfig, $sName); |
||
62 | } |
||
63 | } |
||
0 ignored issues
–
show
|
|||
64 | } |
||
65 |