Skip to content

Commit

Permalink
Wire transport factory service when messenger component is present
Browse files Browse the repository at this point in the history
  • Loading branch information
alcaeus committed Apr 5, 2019
1 parent 4417e02 commit 45817de
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions DependencyInjection/DoctrineExtension.php
Expand Up @@ -21,6 +21,7 @@
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\Messenger\Transport\Doctrine\DoctrineTransportFactory;

/**
* DoctrineExtension is an extension for the Doctrine DBAL and ORM library.
Expand Down Expand Up @@ -797,5 +798,12 @@ private function loadMessengerServices(ContainerBuilder $container) : void

$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('messenger.xml');

if (! class_exists(DoctrineTransportFactory::class)) {
return;
}

$transportFactoryDefinition = $container->getDefinition('messenger.transport.doctrine.factory');
$transportFactoryDefinition->addTag('messenger.transport_factory');
}
}
8 changes: 8 additions & 0 deletions Resources/config/messenger.xml
Expand Up @@ -11,5 +11,13 @@
<service id="messenger.middleware.doctrine_transaction" class="Symfony\Bridge\Doctrine\Messenger\DoctrineTransactionMiddleware" abstract="true" public="false">
<argument type="service" id="doctrine" />
</service>

<!--
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">
<argument type="service" id="doctrine" />
</service>
</services>
</container>

0 comments on commit 45817de

Please sign in to comment.