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

ExecutorBuilderCompilerPass   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 19 2
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