Skip to content

Commit

Permalink
Remove legacy workarounds for Messenger integration
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Nov 16, 2018
1 parent f65455e commit 612cea7
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 115 deletions.
27 changes: 0 additions & 27 deletions DependencyInjection/Compiler/MessengerPass.php

This file was deleted.

9 changes: 3 additions & 6 deletions DependencyInjection/DoctrineExtension.php
Expand Up @@ -11,7 +11,7 @@
use LogicException;
use Symfony\Bridge\Doctrine\DependencyInjection\AbstractDoctrineExtension;
use Symfony\Bridge\Doctrine\Form\Type\DoctrineType;
use Symfony\Bridge\Doctrine\Messenger\DoctrineTransactionMiddlewareFactory;
use Symfony\Bridge\Doctrine\Messenger\DoctrineTransactionMiddleware;
use Symfony\Bridge\Doctrine\PropertyInfo\DoctrineExtractor;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\Alias;
Expand Down Expand Up @@ -393,13 +393,10 @@ protected function ormLoad(array $config, ContainerBuilder $container)
->addTag(ServiceRepositoryCompilerPass::REPOSITORY_SERVICE_TAG);
}

// If the Messenger component is installed and the doctrine transaction middleware factory is available, wire it:
if (interface_exists(MessageBusInterface::class) && class_exists(DoctrineTransactionMiddlewareFactory::class)) {
// If the Messenger component is installed and the doctrine transaction middleware is available, wire it:
if (interface_exists(MessageBusInterface::class) && class_exists(DoctrineTransactionMiddleware::class)) {
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('messenger.xml');

$container->getDefinition('messenger.middleware.doctrine_transaction_middleware')
->replaceArgument(0, $config['default_entity_manager']);
}

/*
Expand Down
2 changes: 0 additions & 2 deletions DoctrineBundle.php
Expand Up @@ -3,7 +3,6 @@
namespace Doctrine\Bundle\DoctrineBundle;

use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\EntityListenerPass;
use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\MessengerPass;
use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\ServiceRepositoryCompilerPass;
use Doctrine\Common\Util\ClassUtils;
use Doctrine\ORM\EntityManager;
Expand Down Expand Up @@ -40,7 +39,6 @@ public function build(ContainerBuilder $container)
$container->addCompilerPass(new DoctrineValidationPass('orm'));
$container->addCompilerPass(new EntityListenerPass());
$container->addCompilerPass(new ServiceRepositoryCompilerPass());
$container->addCompilerPass(new MessengerPass());
}

/**
Expand Down
11 changes: 3 additions & 8 deletions Resources/config/messenger.xml
Expand Up @@ -4,17 +4,12 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="doctrine.orm.messenger.middleware_factory.transaction" class="Symfony\Bridge\Doctrine\Messenger\DoctrineTransactionMiddlewareFactory" public="false">
<argument type="service" id="doctrine" />
</service>

<!--
The following service isn't prefixed by the "doctrine.orm" namespace in order for end-users to just use
the "doctrine_transaction_middleware" shortcut in message buses middleware config
the "doctrine_transaction" shortcut in message buses middleware config
-->
<service id="messenger.middleware.doctrine_transaction_middleware" class="Symfony\Bridge\Doctrine\Messenger\DoctrineTransactionMiddleware" abstract="true" public="false">
<factory service="doctrine.orm.messenger.middleware_factory.transaction" method="createMiddleware" />
<argument /> <!-- default entity manager -->
<service id="messenger.middleware.doctrine_transaction" class="Symfony\Bridge\Doctrine\Messenger\DoctrineTransactionMiddleware" abstract="true" public="false">
<argument type="service" id="doctrine" />
</service>
</services>
</container>
69 changes: 0 additions & 69 deletions Tests/DependencyInjection/Compiler/MessengerPassTest.php

This file was deleted.

5 changes: 2 additions & 3 deletions Tests/DependencyInjection/DoctrineExtensionTest.php
Expand Up @@ -697,9 +697,8 @@ public function testMessengerIntegration()
->build();
$extension->load([$config], $container);

$this->assertNotNull($container->getDefinition('doctrine.orm.messenger.middleware_factory.transaction'));
$this->assertNotNull($middlewarePrototype = $container->getDefinition('messenger.middleware.doctrine_transaction_middleware'));
$this->assertSame('default', $middlewarePrototype->getArgument(0));
$this->assertNotNull($middlewarePrototype = $container->getDefinition('messenger.middleware.doctrine_transaction'));
$this->assertCount(1, $middlewarePrototype->getArguments());
}

public function testCacheConfiguration()
Expand Down

0 comments on commit 612cea7

Please sign in to comment.