Completed
Pull Request — master (#817)
by Maxime
02:16
created

MessengerPass::process()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 3
eloc 5
nc 2
nop 1
1
<?php
2
3
namespace Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\Messenger\MessageBusInterface;
8
9
/**
10
 * Class for Symfony Messenger component integrations
11
 */
12
class MessengerPass implements CompilerPassInterface
13
{
14
    /**
15
     * {@inheritDoc}
16
     */
17
    public function process(ContainerBuilder $container)
18
    {
19
        if ($container->hasAlias('message_bus') && is_subclass_of($container->findDefinition('message_bus')->getClass(), MessageBusInterface::class)) {
0 ignored issues
show
Bug introduced by
Due to PHP Bug #53727, is_subclass_of might return inconsistent results on some PHP versions if \Symfony\Component\Messe...sageBusInterface::class can be an interface. If so, you could instead use ReflectionClass::implementsInterface.
Loading history...
20
            return;
21
        }
22
23
        // Remove wired services if the Messenger component actually isn't enabled:
24
        $container->removeDefinition('doctrine.orm.messenger.middleware_factory.transaction');
25
        $container->removeDefinition('messenger.middleware.doctrine_transaction_middleware');
26
    }
27
}
28