Completed
Push — master ( ff1eea...25d248 )
by Beñat
01:47
created

TacticianPass::process()   B

Complexity

Conditions 3
Paths 2

Size

Total Lines 25
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 25
rs 8.8571
cc 3
eloc 15
nc 2
nop 1
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\DomainEventsPublicationMiddleware;
18
use LIN3S\SharedKernel\Infrastructure\Application\Tactician\Middlewares\PdoTransactionMiddleware;
19
use LIN3S\SharedKernel\Infrastructure\Application\Tactician\TacticianCommandBus;
20
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
21
use Symfony\Component\DependencyInjection\ContainerBuilder;
22
use Symfony\Component\DependencyInjection\Definition;
23
use Symfony\Component\DependencyInjection\Reference;
24
25
/**
26
 * @author Beñat Espiña <[email protected]>
27
 */
28
class TacticianPass implements CompilerPassInterface
29
{
30
    public function process(ContainerBuilder $container) : void
31
    {
32
        if (!class_exists(TacticianBundle::class) || !$container->hasDefinition('tactician.commandbus.default')) {
33
            return;
34
        }
35
36
        $container->setDefinition(
37
            'lin3s.application.tactician_command_bus',
38
            new Definition(TacticianCommandBus::class, [
39
                new Reference('tactician.commandbus'),
40
            ])
41
        );
42
        $container->setDefinition(
43
            'lin3s.tactician_middleware.pdo_transaction',
44
            new Definition(PdoTransactionMiddleware::class, [
45
                new Reference('lin3s.persistence.sql.pdo'),
46
            ])
47
        );
48
        $container->setDefinition(
49
            'lin3s.tactician_middleware.domain_events_publication',
50
            new Definition(DomainEventsPublicationMiddleware::class, [
51
                new Reference('lin3s.persistence.sql.event_store'),
52
            ])
53
        );
54
    }
55
}
56