Skip to content

Commit

Permalink
Remove the Doctrine middleware configuration from the FrameworkBundle
Browse files Browse the repository at this point in the history
  • Loading branch information
sroze committed Apr 4, 2018
1 parent f785bab commit 27a8b1d
Show file tree
Hide file tree
Showing 9 changed files with 0 additions and 77 deletions.
Expand Up @@ -1005,12 +1005,6 @@ function ($a) {
->arrayNode('middlewares')
->addDefaultsIfNotSet()
->children()
->arrayNode('doctrine_transaction')
->canBeEnabled()
->children()
->scalarNode('entity_manager_name')->info('The name of the entity manager to use')->defaultNull()->end()
->end()
->end()
->arrayNode('validation')
->{!class_exists(FullStack::class) && class_exists(Validation::class) ? 'canBeDisabled' : 'canBeEnabled'}()
->end()
Expand Down
Expand Up @@ -13,7 +13,6 @@

use Doctrine\Common\Annotations\Reader;
use Doctrine\Common\Annotations\AnnotationRegistry;
use Symfony\Bridge\Doctrine\Messenger\DoctrineTransactionMiddleware;
use Symfony\Bridge\Monolog\Processor\DebugProcessor;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
Expand Down Expand Up @@ -1454,15 +1453,6 @@ private function registerMessengerConfiguration(array $config, ContainerBuilder
$container->getDefinition('messenger.sender_locator')->replaceArgument(0, $senderLocatorMapping);
$container->getDefinition('messenger.asynchronous.routing.sender_locator')->replaceArgument(1, $messageToSenderIdsMapping);

if ($config['middlewares']['doctrine_transaction']['enabled']) {
if (!class_exists(DoctrineTransactionMiddleware::class)) {
throw new LogicException('The Doctrine transaction middleware is only available when the doctrine bridge is installed. Try running "composer require symfony/doctrine-bridge".');
}
$container->getDefinition('messenger.middleware.doctrine_transaction')->replaceArgument(1, $config['middlewares']['doctrine_transaction']['entity_manager_name']);
} else {
$container->removeDefinition('messenger.middleware.doctrine_transaction');
}

if ($config['middlewares']['validation']['enabled']) {
if (!$container->has('validator')) {
throw new LogicException('The Validation middleware is only available when the Validator component is installed and enabled. Try running "composer require symfony/validator".');
Expand Down
Expand Up @@ -31,13 +31,6 @@
<tag name="message_bus_middleware" priority="100" />
</service>

<service id="messenger.middleware.doctrine_transaction" class="Symfony\Bridge\Doctrine\Messenger\DoctrineTransactionMiddleware">
<argument type="service" id="doctrine" />
<argument /> <!-- Entity manager name -->

<tag name="message_bus_middleware" priority="9" />
</service>

<!-- Asynchronous -->
<service id="messenger.asynchronous.routing.sender_locator" class="Symfony\Component\Messenger\Asynchronous\Routing\SenderLocator">
<argument type="service" id="messenger.sender_locator" />
Expand Down
Expand Up @@ -370,16 +370,10 @@

<xsd:complexType name="messenger_middleware">
<xsd:sequence>
<xsd:element name="doctrine-transaction" type="messenger_doctrine_transaction" minOccurs="0" maxOccurs="1" />
<xsd:element name="validation" type="messenger_validation" minOccurs="0" maxOccurs="1" />
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="messenger_doctrine_transaction">
<xsd:attribute name="entity-manager-name" type="xsd:string" />
<xsd:attribute name="enabled" type="xsd:boolean" />
</xsd:complexType>

<xsd:complexType name="messenger_validation">
<xsd:attribute name="enabled" type="xsd:boolean" />
</xsd:complexType>
Expand Down
Expand Up @@ -254,10 +254,6 @@ class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphor
'enabled' => !class_exists(FullStack::class) && class_exists(MessageBusInterface::class),
'routing' => array(),
'middlewares' => array(
'doctrine_transaction' => array(
'enabled' => false,
'entity_manager_name' => null,
),
'validation' => array(
'enabled' => !class_exists(FullStack::class),
),
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Expand Up @@ -12,7 +12,6 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection;

use Doctrine\Common\Annotations\Annotation;
use Symfony\Bridge\Doctrine\ContainerAwareEventManager;
use Symfony\Bundle\FullStack;
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddAnnotationsCachedReaderPass;
Expand Down Expand Up @@ -521,18 +520,6 @@ public function testMessenger()
$this->assertFalse($container->hasDefinition('messenger.middleware.doctrine_transaction'));
}

public function testMessengerDoctrine()
{
if (!class_exists(ContainerAwareEventManager::class)) {
self::markTestSkipped('Skipping tests since Doctrine bridge is not installed');
}

$container = $this->createContainerFromFile('messenger_doctrine');
$this->assertTrue($container->hasDefinition('messenger.middleware.doctrine_transaction'));
$def = $container->getDefinition('messenger.middleware.doctrine_transaction');
$this->assertEquals('foobar', $def->getArgument(1));
}

public function testMessengerValidationDisabled()
{
if (!class_exists(Validation::class)) {
Expand Down

0 comments on commit 27a8b1d

Please sign in to comment.