IvoryBase64FileExtension::loadInternal()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 19
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 19
ccs 13
cts 13
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 12
nc 4
nop 2
crap 3
1
<?php
2
3
/*
4
 * This file is part of the Ivory Base64 File package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Ivory\Base64FileBundle\DependencyInjection;
13
14
use Symfony\Component\Config\FileLocator;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
17
use Symfony\Component\Form\AbstractType;
18
use Symfony\Component\HttpKernel\DependencyInjection\ConfigurableExtension;
19
20
/**
21
 * @author GeLo <[email protected]>
22
 */
23
class IvoryBase64FileExtension extends ConfigurableExtension
24
{
25
    /**
26
     * {@inheritdoc}
27
     */
28 18
    protected function loadInternal(array $config, ContainerBuilder $container)
29
    {
30 18
        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
31
32 18
        foreach (['form'] as $resource) {
33 18
            $loader->load($resource.'.xml');
34 14
        }
35
36
        $container
37 18
            ->getDefinition($formExtension = 'ivory.base64_file.form.extension')
38 18
            ->addArgument($config['default']);
39
40 18
        if (!method_exists(AbstractType::class, 'getBlockPrefix')) {
41
            $container
42 8
                ->getDefinition($formExtension)
43 8
                ->clearTag('form.type_extension')
44 8
                ->addTag('form.type_extension', ['alias' => 'file']);
45 4
        }
46 18
    }
47
}
48