|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the daikon-cqrs/boot project. |
|
4
|
|
|
* |
|
5
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
6
|
|
|
* file that was distributed with this source code. |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace Daikon\Boot\Bootstrap; |
|
10
|
|
|
|
|
11
|
|
|
use Daikon\Boot\Config\CratesConfigLoader; |
|
12
|
|
|
use Daikon\Config\ArrayConfigLoader; |
|
13
|
|
|
use Daikon\Config\ConfigProvider; |
|
14
|
|
|
use Daikon\Config\ConfigProviderInterface; |
|
15
|
|
|
use Daikon\Config\ConfigProviderParams; |
|
16
|
|
|
use Daikon\Config\YamlConfigLoader; |
|
17
|
|
|
|
|
18
|
|
|
trait BootstrapTrait |
|
19
|
|
|
{ |
|
20
|
|
|
private function loadConfiguration(array $bootParams): ConfigProviderInterface |
|
21
|
|
|
{ |
|
22
|
|
|
$bootParams['daikon'] = ['config_dir' => dirname(dirname(__DIR__)) . '/config']; |
|
23
|
|
|
return new ConfigProvider( |
|
24
|
|
|
new ConfigProviderParams( |
|
25
|
|
|
array_merge( |
|
26
|
|
|
[ |
|
27
|
|
|
'app' => [ |
|
28
|
|
|
'loader' => ArrayConfigLoader::class, |
|
29
|
|
|
'sources' => $bootParams |
|
30
|
|
|
], |
|
31
|
|
|
'crates' => [ |
|
32
|
|
|
'loader' => new CratesConfigLoader([ |
|
33
|
|
|
'crates:' => $bootParams['crates_dir'], |
|
34
|
|
|
'vendor:' => $bootParams['base_dir'].'/vendor' |
|
35
|
|
|
]), |
|
36
|
|
|
'locations' => [$bootParams['config_dir']], |
|
37
|
|
|
'sources' => [ |
|
38
|
|
|
'crates.yml', |
|
39
|
|
|
'crates.${app.context}.yml', |
|
40
|
|
|
'crates.${app.env}.yml', |
|
41
|
|
|
'crates.${app.context}.${app.env}.yml' |
|
42
|
|
|
] |
|
43
|
|
|
] |
|
44
|
|
|
], |
|
45
|
|
|
(new YamlConfigLoader)->load( |
|
46
|
|
|
[ |
|
47
|
|
|
$bootParams['daikon']['config_dir'], |
|
48
|
|
|
$bootParams['config_dir'] |
|
49
|
|
|
], |
|
50
|
|
|
['loaders.yml'] |
|
51
|
|
|
) |
|
52
|
|
|
) |
|
53
|
|
|
) |
|
54
|
|
|
); |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|