[Bridge/Doctrine] remove workarounds from the past

This commit is contained in:
Nicolas Grekas 2018-10-31 17:56:39 +01:00
parent 78192e776c
commit 385856413c
5 changed files with 7 additions and 40 deletions

View File

@ -7,6 +7,7 @@ CHANGELOG
* deprecated injecting `ClassMetadataFactory` in `DoctrineExtractor`,
an instance of `EntityManagerInterface` should be injected instead
* added support for `simple_array` type
* the `DoctrineTransactionMiddlewareFactory` class has been removed
4.1.0
-----

View File

@ -21,13 +21,15 @@ use Symfony\Component\Messenger\Middleware\StackInterface;
* Wraps all handlers in a single doctrine transaction.
*
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
*
* @experimental in 4.2
*/
class DoctrineTransactionMiddleware implements MiddlewareInterface
{
private $managerRegistry;
private $entityManagerName;
public function __construct(ManagerRegistry $managerRegistry, ?string $entityManagerName)
public function __construct(ManagerRegistry $managerRegistry, string $entityManagerName = null)
{
$this->managerRegistry = $managerRegistry;
$this->entityManagerName = $entityManagerName;

View File

@ -1,36 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bridge\Doctrine\Messenger;
use Symfony\Bridge\Doctrine\ManagerRegistry;
/**
* Create a Doctrine ORM transaction middleware to be used in a message bus from an entity manager name.
*
* @author Maxime Steinhausser <maxime.steinhausser@gmail.com>
*
* @final
*/
class DoctrineTransactionMiddlewareFactory
{
private $managerRegistry;
public function __construct(ManagerRegistry $managerRegistry)
{
$this->managerRegistry = $managerRegistry;
}
public function createMiddleware(string $managerName): DoctrineTransactionMiddleware
{
return new DoctrineTransactionMiddleware($this->managerRegistry, $managerName);
}
}

View File

@ -34,7 +34,7 @@ class DoctrineTransactionMiddlewareTest extends MiddlewareTestCase
$managerRegistry = $this->createMock(ManagerRegistry::class);
$managerRegistry->method('getManager')->willReturn($this->entityManager);
$this->middleware = new DoctrineTransactionMiddleware($managerRegistry, null);
$this->middleware = new DoctrineTransactionMiddleware($managerRegistry);
}
public function testMiddlewareWrapsInTransactionAndFlushes()

View File

@ -28,7 +28,7 @@
<argument /> <!-- Bus handler resolver -->
</service>
<service id="messenger.middleware.validation" class="Symfony\Component\Messenger\Middleware\ValidationMiddleware" abstract="true">
<service id="messenger.middleware.validation" class="Symfony\Component\Messenger\Middleware\ValidationMiddleware">
<argument type="service" id="validator" />
</service>
@ -37,7 +37,7 @@
</service>
<!-- Logging -->
<service id="messenger.middleware.logging" class="Symfony\Component\Messenger\Middleware\LoggingMiddleware" abstract="true">
<service id="messenger.middleware.logging" class="Symfony\Component\Messenger\Middleware\LoggingMiddleware">
<tag name="monolog.logger" channel="messenger" />
<argument type="service" id="logger" />
</service>