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

MessengerPass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 14
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 8 3
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
        // Remove wired services if the Messenger component actually isn't enabled:
20
        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...
21
            $container->removeDefinition('doctrine.orm.messenger.middleware_factory.transaction');
22
            $container->removeDefinition('messenger.middleware.doctrine_transaction_middleware');
23
        }
24
    }
25
}
26