minor #30799 [Messenger] Fix the Doctrine transport to use the new interface (sroze)
This PR was merged into the 4.3-dev branch.
Discussion
----------
[Messenger] Fix the Doctrine transport to use the new interface
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #29007
| License | MIT
| Doc PR | ø
Commits
-------
75e3355da5
Fix the Doctrine transport to use the new interface
This commit is contained in:
commit
a9459c0980
@ -16,15 +16,14 @@ use Symfony\Bridge\Doctrine\RegistryInterface;
|
||||
use Symfony\Component\Messenger\Transport\Doctrine\Connection;
|
||||
use Symfony\Component\Messenger\Transport\Doctrine\DoctrineTransport;
|
||||
use Symfony\Component\Messenger\Transport\Doctrine\DoctrineTransportFactory;
|
||||
use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;
|
||||
|
||||
class DoctrineTransportFactoryTest extends TestCase
|
||||
{
|
||||
public function testSupports()
|
||||
{
|
||||
$factory = new DoctrineTransportFactory(
|
||||
$this->getMockBuilder(RegistryInterface::class)->getMock(),
|
||||
null,
|
||||
false
|
||||
$this->getMockBuilder(RegistryInterface::class)->getMock()
|
||||
);
|
||||
|
||||
$this->assertTrue($factory->supports('doctrine://default', []));
|
||||
@ -41,14 +40,12 @@ class DoctrineTransportFactoryTest extends TestCase
|
||||
->method('getConnection')
|
||||
->willReturn($connection);
|
||||
|
||||
$factory = new DoctrineTransportFactory(
|
||||
$registry,
|
||||
null
|
||||
);
|
||||
$factory = new DoctrineTransportFactory($registry);
|
||||
$serializer = $this->createMock(SerializerInterface::class);
|
||||
|
||||
$this->assertEquals(
|
||||
new DoctrineTransport(new Connection(Connection::buildConfiguration('doctrine://default'), $connection), null),
|
||||
$factory->createTransport('doctrine://default', [])
|
||||
new DoctrineTransport(new Connection(Connection::buildConfiguration('doctrine://default'), $connection), $serializer),
|
||||
$factory->createTransport('doctrine://default', [], $serializer)
|
||||
);
|
||||
}
|
||||
|
||||
@ -65,11 +62,7 @@ class DoctrineTransportFactoryTest extends TestCase
|
||||
throw new \InvalidArgumentException();
|
||||
}));
|
||||
|
||||
$factory = new DoctrineTransportFactory(
|
||||
$registry,
|
||||
null
|
||||
);
|
||||
|
||||
$factory->createTransport('doctrine://default', []);
|
||||
$factory = new DoctrineTransportFactory($registry);
|
||||
$factory->createTransport('doctrine://default', [], $this->createMock(SerializerInterface::class));
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,6 @@
|
||||
namespace Symfony\Component\Messenger\Transport\Doctrine;
|
||||
|
||||
use Symfony\Component\Messenger\Envelope;
|
||||
use Symfony\Component\Messenger\Transport\Serialization\PhpSerializer;
|
||||
use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;
|
||||
use Symfony\Component\Messenger\Transport\SetupableTransportInterface;
|
||||
use Symfony\Component\Messenger\Transport\TransportInterface;
|
||||
@ -29,10 +28,10 @@ class DoctrineTransport implements TransportInterface, SetupableTransportInterfa
|
||||
private $receiver;
|
||||
private $sender;
|
||||
|
||||
public function __construct(Connection $connection, SerializerInterface $serializer = null)
|
||||
public function __construct(Connection $connection, SerializerInterface $serializer)
|
||||
{
|
||||
$this->connection = $connection;
|
||||
$this->serializer = $serializer ?? new PhpSerializer();
|
||||
$this->serializer = $serializer;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -13,7 +13,6 @@ namespace Symfony\Component\Messenger\Transport\Doctrine;
|
||||
|
||||
use Symfony\Bridge\Doctrine\RegistryInterface;
|
||||
use Symfony\Component\Messenger\Exception\TransportException;
|
||||
use Symfony\Component\Messenger\Transport\Serialization\PhpSerializer;
|
||||
use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;
|
||||
use Symfony\Component\Messenger\Transport\TransportFactoryInterface;
|
||||
use Symfony\Component\Messenger\Transport\TransportInterface;
|
||||
@ -26,15 +25,13 @@ use Symfony\Component\Messenger\Transport\TransportInterface;
|
||||
class DoctrineTransportFactory implements TransportFactoryInterface
|
||||
{
|
||||
private $registry;
|
||||
private $serializer;
|
||||
|
||||
public function __construct(RegistryInterface $registry, SerializerInterface $serializer = null)
|
||||
public function __construct(RegistryInterface $registry)
|
||||
{
|
||||
$this->registry = $registry;
|
||||
$this->serializer = $serializer ?? new PhpSerializer();
|
||||
}
|
||||
|
||||
public function createTransport(string $dsn, array $options): TransportInterface
|
||||
public function createTransport(string $dsn, array $options, SerializerInterface $serializer): TransportInterface
|
||||
{
|
||||
$configuration = Connection::buildConfiguration($dsn, $options);
|
||||
|
||||
@ -46,7 +43,7 @@ class DoctrineTransportFactory implements TransportFactoryInterface
|
||||
|
||||
$connection = new Connection($configuration, $driverConnection);
|
||||
|
||||
return new DoctrineTransport($connection, $this->serializer);
|
||||
return new DoctrineTransport($connection, $serializer);
|
||||
}
|
||||
|
||||
public function supports(string $dsn, array $options): bool
|
||||
|
Reference in New Issue
Block a user