FOSCKEditorExtension::loadResources()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 11
nc 2
nop 1
dl 0
loc 16
ccs 0
cts 10
cp 0
crap 6
rs 9.9
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the FOSCKEditor Bundle.
5
 *
6
 * (c) 2018 - present  Friends of Symfony
7
 * (c) 2009 - 2017     Eric GELOEN <[email protected]>
8
 *
9
 * For the full copyright and license information, please read the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace FOS\CKEditorBundle\DependencyInjection;
14
15
use Symfony\Component\Config\FileLocator;
16
use Symfony\Component\DependencyInjection\ContainerBuilder;
17
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
18
use Symfony\Component\HttpKernel\DependencyInjection\ConfigurableExtension;
19
20
/**
21
 * @author GeLo <[email protected]>
22
 */
23
final class FOSCKEditorExtension extends ConfigurableExtension
24
{
25
    protected function loadInternal(array $config, ContainerBuilder $container): void
26
    {
27
        $this->loadResources($container);
28
29
        $container->getDefinition('fos_ck_editor.configuration')
30
            ->setArgument(0, $config);
31
32
        $bundles = $container->getParameter('kernel.bundles');
33
34
        if (isset($bundles['IvoryCKEditorBundle'])) {
35
            @trigger_error(
36
                "IvoryCKEditorBundle isn't maintained anymore and should be replaced with FOSCKEditorBundle.",
37
                E_USER_DEPRECATED
38
            );
39
        }
40
    }
41
42
    private function loadResources(ContainerBuilder $container): void
43
    {
44
        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
45
46
        $resources = [
47
            'builder',
48
            'command',
49
            'config',
50
            'form',
51
            'installer',
52
            'renderer',
53
            'twig',
54
        ];
55
56
        foreach ($resources as $resource) {
57
            $loader->load($resource.'.xml');
58
        }
59
    }
60
61
    public function getAlias(): string
62
    {
63
        return 'fos_ck_editor';
64
    }
65
}
66