Completed
Push — master ( 79d36b...3588f7 )
by Eric
66:08 queued 03:30
created

IvoryBase64FileExtension::resolveResources()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 14
ccs 9
cts 9
cp 1
rs 9.4285
cc 3
eloc 7
nc 4
nop 1
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\HttpKernel\DependencyInjection\ConfigurableExtension;
18
use Symfony\Component\HttpKernel\Kernel;
19
20
/**
21
 * @author GeLo <[email protected]>
22
 */
23
class IvoryBase64FileExtension extends ConfigurableExtension
24
{
25
    /**
26
     * {@inheritdoc}
27
     */
28 30
    protected function loadInternal(array $config, ContainerBuilder $container)
29
    {
30 30
        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
31
32 30
        foreach (['form'] as $resource) {
33 30
            $loader->load($resource.'.xml');
34 28
        }
35
36
        $container
37 30
            ->getDefinition($formExtension = 'ivory.base64_file.form.extension')
38 30
            ->addArgument($config['default']);
39
40 30
        if (Kernel::VERSION_ID < 20800) {
41
            $container
42 2
                ->getDefinition($formExtension)
43 2
                ->clearTag('form.type_extension')
44 2
                ->addTag('form.type_extension', ['alias' => 'file']);
45 2
        }
46 30
    }
47
}
48