Skip to content

Commit

Permalink
Merge pull request #1131 from Nyholm/messenger
Browse files Browse the repository at this point in the history
Updated service definition to support Messenger 5.1
  • Loading branch information
alcaeus committed Mar 26, 2020
2 parents efc5ed4 + 0a86d4e commit 26c16fa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions DependencyInjection/DoctrineExtension.php
Expand Up @@ -24,8 +24,8 @@
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Messenger\Bridge\Doctrine\Transport\DoctrineTransportFactory;
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\Messenger\Transport\Doctrine\DoctrineTransportFactory;
use Symfony\Component\PropertyInfo\PropertyInfoExtractorInterface;
use function class_exists;
use function sprintf;
Expand Down Expand Up @@ -842,11 +842,17 @@ private function loadMessengerServices(ContainerBuilder $container) : void
$container->removeDefinition('doctrine.orm.messenger.event_subscriber.doctrine_clear_entity_manager');
}

$transportFactoryDefinition = $container->getDefinition('messenger.transport.doctrine.factory');
if (! class_exists(DoctrineTransportFactory::class)) {
return;
// If symfony/messenger < 5.1
if (! class_exists(\Symfony\Component\Messenger\Transport\Doctrine\DoctrineTransportFactory::class)) {
// Dont add the tag
return;
}

$transportFactoryDefinition->setClass(\Symfony\Component\Messenger\Transport\Doctrine\DoctrineTransportFactory::class);
}

$transportFactoryDefinition = $container->getDefinition('messenger.transport.doctrine.factory');
$transportFactoryDefinition->addTag('messenger.transport_factory');
}

Expand Down
2 changes: 1 addition & 1 deletion Resources/config/messenger.xml
Expand Up @@ -32,7 +32,7 @@
The following service isn't tagged as transport factory because the class may not exist.
The tag is added conditionally in DoctrineExtension.
-->
<service id="messenger.transport.doctrine.factory" class="Symfony\Component\Messenger\Transport\Doctrine\DoctrineTransportFactory" public="false">
<service id="messenger.transport.doctrine.factory" class="Symfony\Component\Messenger\Bridge\Doctrine\Transport\DoctrineTransportFactory" public="false">
<argument type="service" id="doctrine" />
</service>

Expand Down

0 comments on commit 26c16fa

Please sign in to comment.