OldSoundRabbitMqBundle::build()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 7
ccs 0
cts 3
cp 0
crap 2
rs 10
1
<?php
2
3
namespace OldSound\RabbitMqBundle;
4
5
use OldSound\RabbitMqBundle\DependencyInjection\Compiler\InjectEventDispatcherPass;
6
use OldSound\RabbitMqBundle\DependencyInjection\Compiler\RegisterPartsPass;
7
use OldSound\RabbitMqBundle\DependencyInjection\Compiler\ServiceContainerPass;
8
use Symfony\Component\HttpKernel\Bundle\Bundle;
9
use Symfony\Component\DependencyInjection\ContainerBuilder;
10
11
class OldSoundRabbitMqBundle extends Bundle
12
{
13
    public function build(ContainerBuilder $container): void
14
    {
15
        parent::build($container);
16
17
        $container->addCompilerPass(new RegisterPartsPass());
18
        $container->addCompilerPass(new InjectEventDispatcherPass());
19
        $container->addCompilerPass(new ServiceContainerPass());
20
    }
21
22
    /**
23
     * {@inheritDoc}
24
     */
25
    public function shutdown(): void
26
    {
27
        parent::shutdown();
28
        if (!$this->container->hasParameter('old_sound_rabbit_mq.base_amqp')) {
29
            return;
30
        }
31
        $connections = $this->container->getParameter('old_sound_rabbit_mq.base_amqp');
32
        foreach ($connections as $connection) {
33
            if ($this->container->initialized($connection)) {
34
                $this->container->get($connection)->close();
35
            }
36
        }
37
    }
38
}
39