Code

< 40 %
40-60 %
> 60 %
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