Completed
Pull Request — master (#138)
by Marko
27:49 queued 12:51
created

FOSCKEditorExtension::resolveStylesSet()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
cc 4
eloc 7
nc 4
nop 1
dl 0
loc 15
rs 10
c 0
b 0
f 0
ccs 0
cts 10
cp 0
crap 20
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\Form\AbstractType;
19
use Symfony\Component\HttpKernel\DependencyInjection\ConfigurableExtension;
20
21
/**
22
 * @author GeLo <[email protected]>
23
 */
24
class FOSCKEditorExtension extends ConfigurableExtension
25
{
26
    protected function loadInternal(array $config, ContainerBuilder $container)
27
    {
28
        $this->loadResources($container);
29
30
        $container->getDefinition('fos_ck_editor.configuration')
31
            ->setArgument(0, $config);
32
33
        if (!method_exists(AbstractType::class, 'getBlockPrefix')) {
34
            $container->getDefinition('fos_ck_editor.form.type')
35
                ->clearTag('form.type')
36
                ->addTag('form.type', ['alias' => 'ckeditor']);
37
        }
38
39
        $bundles = $container->getParameter('kernel.bundles');
40
41
        if (isset($bundles['IvoryCKEditorBundle'])) {
42
            @trigger_error(
43
                "IvoryCKEditorBundle isn't maintained anymore and should be replaced with FOSCKEditorBundle.",
44
                E_USER_DEPRECATED
45
            );
46
        }
47
    }
48
49
    private function loadResources(ContainerBuilder $container)
50
    {
51
        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
52
53
        $resources = [
54
            'builder',
55
            'command',
56
            'config',
57
            'form',
58
            'installer',
59
            'renderer',
60
            'twig',
61
        ];
62
63
        foreach ($resources as $resource) {
64
            $loader->load($resource.'.xml');
65
        }
66
    }
67
68
    public function getAlias()
69
    {
70
        return 'fos_ck_editor';
71
    }
72
}
73