A2lixAutoFormExtension::load()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 2
dl 0
loc 13
rs 10
c 0
b 0
f 0
ccs 0
cts 10
cp 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the AutoFormBundle package.
7
 *
8
 * (c) David ALLIX <http://a2lix.fr>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace A2lix\AutoFormBundle\DependencyInjection;
15
16
use Symfony\Component\Config\Definition\Processor;
17
use Symfony\Component\Config\FileLocator;
18
use Symfony\Component\DependencyInjection\ContainerBuilder;
19
use Symfony\Component\DependencyInjection\Loader;
20
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
21
22
class A2lixAutoFormExtension extends Extension
23
{
24
    public function load(array $configs, ContainerBuilder $container): void
25
    {
26
        $processor = new Processor();
27
        $config = $processor->processConfiguration(new Configuration(), $configs);
28
29
        $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
30
        $loader->load('a2lix_form.xml');
31
        $loader->load('object_info.xml');
32
33
        $definition = $container->getDefinition('a2lix_auto_form.form.manipulator.doctrine_orm_manipulator');
34
        $definition->replaceArgument(1, $config['excluded_fields']);
35
36
        $container->setAlias('a2lix_auto_form.manipulator.default', 'a2lix_auto_form.form.manipulator.doctrine_orm_manipulator');
37
    }
38
}
39