Completed
Pull Request — master (#138)
by Marko
13:58
created

FOSCKEditorExtension::addDefaultToolbars()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 6
rs 10
c 0
b 0
f 0
ccs 0
cts 4
cp 0
crap 2
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 FOS\CKEditorBundle\Exception\DependencyInjectionException;
0 ignored issues
show
Bug introduced by
The type FOS\CKEditorBundle\Excep...dencyInjectionException was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

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