IvoryBase64FileExtension   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 100%

Importance

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

1 Method

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