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 Auryn\Injector; |
12
|
|
|
use Daikon\Boot\Console\Command\ImportFixture; |
13
|
|
|
use Daikon\Boot\Console\Command\ListConfig; |
14
|
|
|
use Daikon\Boot\Console\Command\ListCrates; |
15
|
|
|
use Daikon\Boot\Console\Command\ListProjectors; |
16
|
|
|
use Daikon\Boot\Console\Command\ListRoutes; |
17
|
|
|
use Daikon\Boot\Console\Command\Migrate\CreateMigration; |
18
|
|
|
use Daikon\Boot\Console\Command\Migrate\ListTargets; |
19
|
|
|
use Daikon\Boot\Console\Command\Migrate\MigrateDown; |
20
|
|
|
use Daikon\Boot\Console\Command\Migrate\MigrateUp; |
21
|
|
|
use Daikon\Boot\Console\Command\RunWorker; |
22
|
|
|
use Daikon\Boot\Service\ServiceProvisioner; |
23
|
|
|
use Daikon\Config\ConfigProvider; |
24
|
|
|
use Daikon\Config\ConfigProviderInterface; |
25
|
|
|
use Psr\Container\ContainerInterface; |
26
|
|
|
|
27
|
|
|
final class ConsoleBootstrap implements BootstrapInterface |
28
|
|
|
{ |
29
|
|
|
use BootstrapTrait; |
30
|
|
|
|
31
|
|
|
public function __invoke(Injector $injector, array $bootParams): ContainerInterface |
32
|
|
|
{ |
33
|
|
|
$configProvider = $this->loadConfiguration($bootParams); |
34
|
|
|
|
35
|
|
|
$injector |
36
|
|
|
->share($injector) |
37
|
|
|
->share($configProvider) |
38
|
|
|
->alias(ConfigProviderInterface::class, ConfigProvider::class); |
39
|
|
|
|
40
|
|
|
$container = (new ServiceProvisioner)->provision($injector, $configProvider); |
41
|
|
|
|
42
|
|
|
$injector |
43
|
|
|
->share($container) |
44
|
|
|
->alias(ContainerInterface::class, get_class($container)) |
45
|
|
|
->defineParam( |
46
|
|
|
'consoleCommands', |
47
|
|
|
array_map([$container, 'get'], [ |
48
|
|
|
CreateMigration::class, |
49
|
|
|
ImportFixture::class, |
50
|
|
|
ListConfig::class, |
51
|
|
|
ListCrates::class, |
52
|
|
|
ListProjectors::class, |
53
|
|
|
ListRoutes::class, |
54
|
|
|
ListTargets::class, |
55
|
|
|
MigrateUp::class, |
56
|
|
|
MigrateDown::class, |
57
|
|
|
RunWorker::class |
58
|
|
|
]) |
59
|
|
|
); |
60
|
|
|
|
61
|
|
|
return $container; |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|