From 7fac93ff8bcd4f26118f7f032bd88ee8a0fdc844 Mon Sep 17 00:00:00 2001 From: Tim Nagel Date: Sun, 4 Jan 2015 20:16:32 +1100 Subject: [PATCH] Fix mongodb doctrine listener --- CHANGELOG-3.1.md | 11 +++++++---- DependencyInjection/FOSElasticaExtension.php | 16 +++++++++++----- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/CHANGELOG-3.1.md b/CHANGELOG-3.1.md index 730126f..0ce44ad 100644 --- a/CHANGELOG-3.1.md +++ b/CHANGELOG-3.1.md @@ -9,8 +9,11 @@ https://github.com/FriendsOfSymfony/FOSElasticaBundle/commit/XXX where XXX is the commit hash. To get the diff between two versions, go to https://github.com/FriendsOfSymfony/FOSElasticaBundle/compare/v3.0.4...v3.1.0 -* 3.1.0 +* 3.1.0 (Unreleased) -* BC BREAK: `DoctrineListener#scheduleForDeletion` access changed to private. -* BC BREAK: `ObjectPersisterInterface` gains the method `handlesObject` that - returns a boolean value if it will handle a given object or not. + * BC BREAK: `Doctrine\Listener#scheduleForDeletion` access changed to private. + * BC BREAK: `ObjectPersisterInterface` gains the method `handlesObject` that + returns a boolean value if it will handle a given object or not. + * Removed `Doctrine\Listener#getSubscribedEvents`. The container + configuration now configures tags with the methods to call to avoid loading + this class on every request where doctrine is active. diff --git a/DependencyInjection/FOSElasticaExtension.php b/DependencyInjection/FOSElasticaExtension.php index 51b092b..565ba33 100644 --- a/DependencyInjection/FOSElasticaExtension.php +++ b/DependencyInjection/FOSElasticaExtension.php @@ -473,14 +473,20 @@ class FOSElasticaExtension extends Extension $listenerDef->replaceArgument(3, new Reference($typeConfig['listener']['logger'])); } + $tagName = null; switch ($typeConfig['driver']) { case 'orm': - foreach ($this->getDoctrineEvents($typeConfig) as $event) { - $listenerDef->addTag('doctrine.event_listener', array('event' => $event)); - } - + $tagName = 'doctrine.event_listener'; break; - case 'mongodb': $listenerDef->addTag('doctrine_mongodb.odm.event_subscriber'); break; + case 'mongodb': + $tagName = 'doctrine_mongodb.odm.event_listener'; + break; + } + + if ($tagName) { + foreach ($this->getDoctrineEvents($typeConfig) as $event) { + $listenerDef->addTag($tagName, array('event' => $event)); + } } $container->setDefinition($listenerId, $listenerDef);