Skip to content

Commit

Permalink
[WIP] ping/close connection middleware services
Browse files Browse the repository at this point in the history
  • Loading branch information
insidestyles committed Apr 22, 2019
1 parent 2fb807c commit 71040f7
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
10 changes: 10 additions & 0 deletions DependencyInjection/DoctrineExtension.php
Expand Up @@ -11,6 +11,8 @@
use Doctrine\ORM\Version;
use LogicException;
use Symfony\Bridge\Doctrine\DependencyInjection\AbstractDoctrineExtension;
use Symfony\Bridge\Doctrine\Messenger\DoctrineCloseConnectionMiddleware;
use Symfony\Bridge\Doctrine\Messenger\DoctrinePingConnectionMiddleware;
use Symfony\Bridge\Doctrine\Messenger\DoctrineTransactionMiddleware;
use Symfony\Bridge\Doctrine\PropertyInfo\DoctrineExtractor;
use Symfony\Bridge\Doctrine\Validator\DoctrineLoader;
Expand Down Expand Up @@ -849,6 +851,14 @@ private function loadMessengerServices(ContainerBuilder $container) : void
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('messenger.xml');

if (class_exists(DoctrineCloseConnectionMiddleware::class)) {
$loader->load('messenger/doctrine-close-connection-middleware.xml');
}

if (class_exists(DoctrinePingConnectionMiddleware::class)) {
$loader->load('messenger/doctrine-ping-connection-middleware.xml');
}

if (! class_exists(DoctrineTransportFactory::class)) {
return;
}
Expand Down
16 changes: 16 additions & 0 deletions Resources/config/messenger/doctrine-ping-close-middleware.xml
@@ -0,0 +1,16 @@
<?xml version="1.0" ?>

<container xmlns="http://symfony.com/schema/dic/services"
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>
<!--
The following service isn't prefixed by the "doctrine.orm" namespace in order for end-users to just use
the "doctrine_close_connection" shortcut in message buses middleware config
-->

<service id="messenger.middleware.doctrine_close_connection" class="Symfony\Bridge\Doctrine\Messenger\DoctrineCloseConnectionMiddleware" abstract="true" public="false">
<argument type="service" id="doctrine" />
</service>
</services>
</container>
15 changes: 15 additions & 0 deletions Resources/config/messenger/doctrine-ping-connection-middleware.xml
@@ -0,0 +1,15 @@
<?xml version="1.0" ?>

<container xmlns="http://symfony.com/schema/dic/services"
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>
<!--
The following service isn't prefixed by the "doctrine.orm" namespace in order for end-users to just use
the "doctrine_ping_connection" shortcut in message buses middleware config
-->
<service id="messenger.middleware.doctrine_ping_connection" class="Symfony\Bridge\Doctrine\Messenger\DoctrinePingConnectionMiddleware" abstract="true" public="false">
<argument type="service" id="doctrine" />
</service>
</services>
</container>

0 comments on commit 71040f7

Please sign in to comment.