Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated service definition to support Messenger 5.1 #1131

Merged
merged 3 commits into from Mar 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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)) {
ostrolucky marked this conversation as resolved.
Show resolved Hide resolved
// 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