Completed
Push — master ( 0df547...e52edd )
by Nikola
08:01
created

ExecutorBuilderCompilerPass   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 25
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 19 2
1
<?php
2
/*
3
 * This file is part of the QueryResourcesLoaderBundle, an RunOpenCode project.
4
 *
5
 * (c) 2017 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
/**
19
 * Class ExecutorBuilderCompilerPass
20
 *
21
 * Builds default query executor for Doctrine Dbal default connection (if possible).
22
 *
23
 * @package RunOpenCode\Bundle\QueryResourcesLoader\DependencyInjection\CompilerPass
24
 */
25
class ExecutorBuilderCompilerPass implements CompilerPassInterface
26
{
27
    /**
28
     * {@inheritdoc}
29
     */
30 2
    public function process(ContainerBuilder $container)
31
    {
32 2
        if ($container->hasDefinition('doctrine.dbal.default_connection')) {
33
34 1
            $definition = new Definition();
35
36
            $definition
37 1
                ->setClass(DoctrineDbalExecutor::class)
38 1
                ->setArguments(array(new Reference('doctrine.dbal.default_connection')))
39 1
                ->setPublic(false)
40
            ;
41
42 1
            $definition->addTag('run_open_code.query_resources_loader.executor', array(
43
                'name' => 'doctrine_dbal_default_connection_executor'
44 1
            ));
45
46 1
            $container->setDefinition('run_open_code.query_resources_loader.executor.doctrine_dbal_default_connection_executor', $definition);
47
        }
48 2
    }
49
}
50