Completed
Push — master ( 91bc8f...12870b )
by Nikola
05:50
created

ExecutorBuilderCompilerPass::process()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 19
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 19
rs 9.4285
cc 2
eloc 10
nc 2
nop 1
1
<?php
2
/*
3
 * This file is part of the QueryResourcesLoader Bundle, an RunOpenCode project.
4
 *
5
 * (c) 2016 RunOpenCode
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace RunOpenCode\Bundle\QueryResourcesLoader\DependencyInjection\CompilerPass;
11
12
use RunOpenCode\Bundle\QueryResourcesLoader\Executor\DoctrineDbalExecutor;
13
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
14
use Symfony\Component\DependencyInjection\ContainerBuilder;
15
use Symfony\Component\DependencyInjection\Definition;
16
use Symfony\Component\DependencyInjection\Reference;
17
18
class ExecutorBuilderCompilerPass implements CompilerPassInterface
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function process(ContainerBuilder $container)
24
    {
25
        if ($container->hasDefinition('doctrine.dbal.default_connection')) {
26
27
            $definition = new Definition();
28
29
            $definition
30
                ->setClass(DoctrineDbalExecutor::class)
31
                ->setArguments(array(new Reference('doctrine.dbal.default_connection')))
32
                ->setPublic(false)
33
            ;
34
35
            $definition->addTag('run_open_code.query_resources_loader.executor', array(
36
                'name' => 'doctrine_dbal_default_connection_executor'
37
            ));
38
39
            $container->setDefinition('run_open_code.query_resources_loader.executor.doctrine_dbal_default_connection_executor', $definition);
40
        }
41
    }
42
}
43