|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Shared Kernel library. |
|
5
|
|
|
* |
|
6
|
|
|
* Copyright (c) 2016-present LIN3S <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
declare(strict_types=1); |
|
13
|
|
|
|
|
14
|
|
|
namespace LIN3S\SharedKernel\Infrastructure\Symfony\Bundle\DependencyInjection\Compiler; |
|
15
|
|
|
|
|
16
|
|
|
use League\Tactician\Bundle\TacticianBundle; |
|
17
|
|
|
use LIN3S\SharedKernel\Infrastructure\Application\Tactician\Middlewares\AppendDomainEventsToStoreMiddleware; |
|
18
|
|
|
use LIN3S\SharedKernel\Infrastructure\Application\Tactician\Middlewares\DomainEventsPublicationMiddleware; |
|
19
|
|
|
use LIN3S\SharedKernel\Infrastructure\Application\Tactician\Middlewares\PdoTransactionMiddleware; |
|
20
|
|
|
use LIN3S\SharedKernel\Infrastructure\Application\Tactician\TacticianCommandBus; |
|
21
|
|
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
|
22
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
23
|
|
|
use Symfony\Component\DependencyInjection\Definition; |
|
24
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @author Beñat Espiña <[email protected]> |
|
28
|
|
|
*/ |
|
29
|
|
|
class TacticianCommandBusPass implements CompilerPassInterface |
|
30
|
|
|
{ |
|
31
|
|
|
public function process(ContainerBuilder $container) : void |
|
32
|
|
|
{ |
|
33
|
|
|
if (!class_exists(TacticianBundle::class) || !$container->hasDefinition('tactician.commandbus.default')) { |
|
34
|
|
|
return; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
$container->setDefinition( |
|
38
|
|
|
'lin3s.application.tactician_command_bus', |
|
39
|
|
|
new Definition(TacticianCommandBus::class, [ |
|
40
|
|
|
new Reference('tactician.commandbus'), |
|
41
|
|
|
]) |
|
42
|
|
|
); |
|
43
|
|
|
$container->setDefinition( |
|
44
|
|
|
'lin3s.tactician_middleware.pdo_transaction', |
|
45
|
|
|
new Definition(PdoTransactionMiddleware::class, [ |
|
46
|
|
|
new Reference('lin3s.persistence.sql.pdo'), |
|
47
|
|
|
]) |
|
48
|
|
|
); |
|
49
|
|
|
$container->setDefinition( |
|
50
|
|
|
'lin3s.tactician_middleware.append_domain_events_to_store', |
|
51
|
|
|
new Definition(AppendDomainEventsToStoreMiddleware::class, [ |
|
52
|
|
|
new Reference('lin3s.persistence.sql.event_store'), |
|
53
|
|
|
]) |
|
54
|
|
|
); |
|
55
|
|
|
$container->setDefinition( |
|
56
|
|
|
'lin3s.tactician_middleware.domain_events_publication', |
|
57
|
|
|
new Definition(DomainEventsPublicationMiddleware::class, [ |
|
58
|
|
|
new Reference('lin3s.event_bus') |
|
59
|
|
|
]) |
|
60
|
|
|
); |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|