Completed
Pull Request — master (#1)
by Jim
08:57
created

EntityManagerCompilerPass   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 3
dl 0
loc 17
c 0
b 0
f 0
rs 10

1 Method

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