1 | <?php |
||
16 | final class BusBuilder |
||
17 | { |
||
18 | /** |
||
19 | * @var string |
||
20 | */ |
||
21 | private $busId; |
||
22 | |||
23 | /** |
||
24 | * @var string[] |
||
25 | */ |
||
26 | private $middlewareIds = []; |
||
27 | |||
28 | /** |
||
29 | * @var string |
||
30 | */ |
||
31 | private $methodInflectorId; |
||
32 | |||
33 | 111 | public function __construct(string $busId, string $methodInflector, array $middlewareIds) |
|
39 | |||
40 | 108 | public function id(): string |
|
44 | |||
45 | 75 | public function serviceId(): string |
|
49 | |||
50 | 75 | public function locatorServiceId() |
|
54 | |||
55 | 75 | public function commandHandlerMiddlewareId(): string |
|
59 | |||
60 | 69 | public function registerInContainer(ContainerBuilder $container, array $commandsToAccept) |
|
89 | |||
90 | 69 | private function registerLocatorService(ContainerBuilder $container, $commandsToAccept) |
|
91 | { |
||
92 | // Leverage symfony/dependency-injection:^3.3 service locators |
||
93 | 69 | if (class_exists(ServiceLocator::class)) { |
|
94 | 46 | $definition = new Definition( |
|
95 | 46 | ContainerLocator::class, |
|
96 | 46 | [new Reference($this->registerHandlerServiceLocator($container, $commandsToAccept)), $commandsToAccept] |
|
97 | ); |
||
98 | } else { |
||
99 | 23 | $definition = new Definition( |
|
100 | 23 | ContainerBasedHandlerLocator::class, |
|
101 | 23 | [new Reference('service_container'), $commandsToAccept] |
|
102 | ); |
||
103 | } |
||
104 | |||
105 | 69 | $container->setDefinition($this->locatorServiceId(), $definition); |
|
106 | 69 | } |
|
107 | |||
108 | 46 | private function registerHandlerServiceLocator(ContainerBuilder $container, array $commandsToAccept): string |
|
126 | } |
||
127 |