From 34197adc04d719219032c9fb6889c83cfed93126 Mon Sep 17 00:00:00 2001 From: shustrik Date: Tue, 2 Aug 2016 22:58:41 +0300 Subject: [PATCH] issue #377 --- DependencyInjection/Compiler/RegisterPartsPass.php | 2 ++ OldSoundRabbitMqBundle.php | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/DependencyInjection/Compiler/RegisterPartsPass.php b/DependencyInjection/Compiler/RegisterPartsPass.php index c8b23413..9285f384 100644 --- a/DependencyInjection/Compiler/RegisterPartsPass.php +++ b/DependencyInjection/Compiler/RegisterPartsPass.php @@ -10,6 +10,8 @@ class RegisterPartsPass implements CompilerPassInterface { public function process(ContainerBuilder $container) { + $services = $container->findTaggedServiceIds('old_sound_rabbit_mq.base_amqp'); + $container->setParameter('old_sound_rabbit_mq.base_amqp', array_keys($services)); if (!$container->hasDefinition('old_sound_rabbit_mq.parts_holder')) { return; } diff --git a/OldSoundRabbitMqBundle.php b/OldSoundRabbitMqBundle.php index 3cdc0516..d9725163 100644 --- a/OldSoundRabbitMqBundle.php +++ b/OldSoundRabbitMqBundle.php @@ -23,10 +23,14 @@ public function build(ContainerBuilder $container) public function shutdown() { parent::shutdown(); - $partHolder = $this->container->get('old_sound_rabbit_mq.parts_holder'); - $connections = $partHolder->getParts("old_sound_rabbit_mq.base_amqp"); + if (!$this->container->hasParameter('old_sound_rabbit_mq.base_amqp')) { + return; + } + $connections = $this->container->getParameter('old_sound_rabbit_mq.base_amqp'); foreach ($connections as $connection) { - $connection->close(); + if ($this->container->initialized($connection)) { + $this->container->get($connection)->close(); + } } } }