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

EntityManagerCompilerPass::process()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 5
nc 1
nop 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
}