EntityManagerCompilerPass   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 23
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 14 2
1
<?php
2
3
4
namespace Jarobe\TaskRunnerBundle\DependencyInjection\Compiler;
5
6
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
7
use Symfony\Component\DependencyInjection\ContainerBuilder;
8
use Symfony\Component\DependencyInjection\Reference;
9
10
class EntityManagerCompilerPass implements CompilerPassInterface
11
{
12
13
    /**
14
     * You can modify the container here before it is dumped to PHP code.
15
     *
16
     * @param ContainerBuilder $container
17
     */
18
    public function process(ContainerBuilder $container)
19
    {
20
        $entityManagerName = $container->getParameter('jarobe.task_runner.entity_manager');
21
        if ($entityManagerName === null) {
22
            $entityManagerName = 'doctrine.orm.entity_manager';
23
        }
24
        $entityManagerReference = new Reference($entityManagerName);
25
26
        $taskEventManagerDefinition = $container->getDefinition('jarobe.task_runner.task_event_manager');
27
        $taskEventManagerDefinition->replaceArgument(0, $entityManagerReference);
28
29
        $taskEventRepository = $container->getDefinition('jarobe.task_runner.task_event_repository');
30
        $taskEventRepository->setFactory([$entityManagerReference, 'getRepository']);
31
    }
32
}
33