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
|
|
|
|