SymballReportExtension::load()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 13
nc 1
nop 2
1
<?php
2
3
/*
4
 * This file is part of the ReportBundle package
5
 * 
6
 * (c) symball <http://simonball.me>
7
 * 
8
 * For the full copyright and license information, please view the LICENSE file 
9
 * that was distributed with this source code.
10
 */
11
12
namespace Symball\ReportBundle\DependencyInjection;
13
14
use Symfony\Component\DependencyInjection\ContainerBuilder;
15
use Symfony\Component\Config\FileLocator;
16
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
17
use Symfony\Component\DependencyInjection\Loader;
18
use Symfony\Component\DependencyInjection\Reference;
19
20
class SymballReportExtension extends Extension
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function load(array $configs, ContainerBuilder $container)
26
    {
27
        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
28
        $loader->load('services.yml');
29
30
        $configuration = new Configuration();
31
        $config = $this->processConfiguration($configuration, $configs);
32
33
        $definition = $container->getDefinition('symball_report.excel_service');
34
        $definition->replaceArgument(0, $config['default_report_path']);
35
        $definition->replaceArgument(1, $config['excel_factory_namespace']);
36
        $definition->replaceArgument(2, $config['output_format']);
37
38
        $builderDefinition = $container->getDefinition('symball_report.report_builder');
39
        $builderDefinition->replaceArgument(0, new Reference('symball_report.excel_service'));
40
41
        $navServiceName = 'symball_report.navigation.' . $config['layout_style'];
42
        $builderDefinition->replaceArgument(2, new Reference($navServiceName));
43
    }
44
}
45