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

Remove legacy workarounds for Messenger integration #872

Merged
merged 1 commit into from Nov 16, 2018
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
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">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change breaks a test:

$this->assertNotNull($container->getDefinition('doctrine.orm.messenger.middleware_factory.transaction'));
$this->assertNotNull($middlewarePrototype = $container->getDefinition('messenger.middleware.doctrine_transaction_middleware'));

https://travis-ci.org/doctrine/DoctrineBundle/jobs/448961134

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests fixed thanks for the direct links.

<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