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\Definition\Builder\ArrayNodeDefinition; |
||||
16 | use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
||||
17 | use Symfony\Component\Config\Definition\ConfigurationInterface; |
||||
18 | |||||
19 | /** |
||||
20 | * @author GeLo <[email protected]> |
||||
21 | */ |
||||
22 | final class Configuration implements ConfigurationInterface |
||||
23 | { |
||||
24 | public function getConfigTreeBuilder(): TreeBuilder |
||||
25 | { |
||||
26 | if (\method_exists(TreeBuilder::class, 'getRootNode')) { |
||||
27 | $treeBuilder = new TreeBuilder('fos_ck_editor'); |
||||
28 | $rootNode = $treeBuilder->getRootNode(); |
||||
29 | } else { |
||||
30 | // BC layer for symfony/config 4.1 and older |
||||
31 | $treeBuilder = new TreeBuilder(); |
||||
32 | $rootNode = $treeBuilder->root('fos_ck_editor'); |
||||
0 ignored issues
–
show
|
|||||
33 | } |
||||
34 | |||||
35 | $rootNode |
||||
36 | ->children() |
||||
37 | ->booleanNode('enable')->defaultTrue()->end() |
||||
38 | ->booleanNode('async')->defaultFalse()->end() |
||||
39 | ->booleanNode('auto_inline')->defaultTrue()->end() |
||||
40 | ->booleanNode('inline')->defaultFalse()->end() |
||||
41 | ->booleanNode('autoload')->defaultTrue()->end() |
||||
42 | ->booleanNode('jquery')->defaultFalse()->end() |
||||
43 | ->booleanNode('require_js')->defaultFalse()->end() |
||||
44 | ->booleanNode('input_sync')->defaultFalse()->end() |
||||
45 | ->scalarNode('base_path')->defaultValue('bundles/fosckeditor/')->end() |
||||
46 | ->scalarNode('js_path')->defaultValue('bundles/fosckeditor/ckeditor.js')->end() |
||||
47 | ->scalarNode('jquery_path')->defaultValue('bundles/fosckeditor/adapters/jquery.js')->end() |
||||
48 | ->scalarNode('default_config')->defaultValue(null)->end() |
||||
49 | ->append($this->createConfigsNode()) |
||||
50 | ->append($this->createPluginsNode()) |
||||
51 | ->append($this->createStylesNode()) |
||||
52 | ->append($this->createTemplatesNode()) |
||||
53 | ->append($this->createFilebrowsersNode()) |
||||
54 | ->append($this->createToolbarsNode()) |
||||
55 | ->end(); |
||||
56 | |||||
57 | return $treeBuilder; |
||||
58 | } |
||||
59 | |||||
60 | private function createConfigsNode(): ArrayNodeDefinition |
||||
61 | { |
||||
62 | return $this->createPrototypeNode('configs') |
||||
63 | ->arrayPrototype() |
||||
64 | ->normalizeKeys(false) |
||||
65 | ->useAttributeAsKey('name') |
||||
66 | ->variablePrototype()->end() |
||||
67 | ->end(); |
||||
0 ignored issues
–
show
The method
end() does not exist on Symfony\Component\Config...der\NodeParentInterface . It seems like you code against a sub-type of said class. However, the method does not exist in Symfony\Component\Config...ion\Builder\TreeBuilder . Are you sure you never get one of those?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
68 | } |
||||
69 | |||||
70 | private function createPluginsNode(): ArrayNodeDefinition |
||||
71 | { |
||||
72 | return $this->createPrototypeNode('plugins') |
||||
73 | ->arrayPrototype() |
||||
74 | ->children() |
||||
75 | ->scalarNode('path')->end() |
||||
76 | ->scalarNode('filename')->end() |
||||
0 ignored issues
–
show
The method
scalarNode() does not exist on Symfony\Component\Config...der\NodeParentInterface . It seems like you code against a sub-type of Symfony\Component\Config...der\NodeParentInterface such as Symfony\Component\Config...ion\Builder\NodeBuilder .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
77 | ->end() |
||||
78 | ->end(); |
||||
79 | } |
||||
80 | |||||
81 | private function createStylesNode(): ArrayNodeDefinition |
||||
82 | { |
||||
83 | return $this->createPrototypeNode('styles') |
||||
84 | ->arrayPrototype() |
||||
85 | ->arrayPrototype() |
||||
86 | ->children() |
||||
87 | ->scalarNode('name')->end() |
||||
88 | ->scalarNode('type')->end() |
||||
89 | ->scalarNode('widget')->end() |
||||
90 | ->variableNode('element')->end() |
||||
91 | ->append($this->createPrototypeNode('styles')->prototype('scalar')->end()) |
||||
92 | ->append($this->createPrototypeNode('attributes')->prototype('scalar')->end()) |
||||
93 | ->end() |
||||
94 | ->end() |
||||
95 | ->end(); |
||||
96 | } |
||||
97 | |||||
98 | private function createTemplatesNode(): ArrayNodeDefinition |
||||
99 | { |
||||
100 | return $this->createPrototypeNode('templates') |
||||
101 | ->arrayPrototype() |
||||
102 | ->children() |
||||
103 | ->scalarNode('imagesPath')->end() |
||||
104 | ->arrayNode('templates') |
||||
0 ignored issues
–
show
The method
arrayNode() does not exist on Symfony\Component\Config...der\NodeParentInterface . It seems like you code against a sub-type of Symfony\Component\Config...der\NodeParentInterface such as Symfony\Component\Config...ion\Builder\NodeBuilder .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
105 | ->arrayPrototype() |
||||
106 | ->children() |
||||
107 | ->scalarNode('title')->end() |
||||
108 | ->scalarNode('image')->end() |
||||
109 | ->scalarNode('description')->end() |
||||
110 | ->scalarNode('html')->end() |
||||
111 | ->scalarNode('template')->end() |
||||
112 | ->append($this->createPrototypeNode('template_parameters')->prototype('scalar')->end()) |
||||
113 | ->end() |
||||
114 | ->end() |
||||
115 | ->end() |
||||
116 | ->end() |
||||
117 | ->end(); |
||||
118 | } |
||||
119 | |||||
120 | private function createFilebrowsersNode(): ArrayNodeDefinition |
||||
121 | { |
||||
122 | $node = $this->createNode('filebrowsers') |
||||
123 | ->useAttributeAsKey('name') |
||||
124 | ->scalarPrototype() |
||||
125 | ->end(); |
||||
126 | |||||
127 | \assert($node instanceof ArrayNodeDefinition); |
||||
128 | |||||
129 | return $node; |
||||
130 | } |
||||
131 | |||||
132 | private function createToolbarsNode(): ArrayNodeDefinition |
||||
133 | { |
||||
134 | return $this->createNode('toolbars') |
||||
135 | ->addDefaultsIfNotSet() |
||||
136 | ->children() |
||||
137 | ->arrayNode('configs') |
||||
138 | ->useAttributeAsKey('name') |
||||
139 | ->arrayPrototype() |
||||
140 | ->variablePrototype()->end() |
||||
141 | ->end() |
||||
142 | ->end() |
||||
143 | ->arrayNode('items') |
||||
144 | ->useAttributeAsKey('name') |
||||
145 | ->arrayPrototype() |
||||
146 | ->variablePrototype()->end() |
||||
147 | ->end() |
||||
148 | ->end() |
||||
149 | ->end(); |
||||
150 | } |
||||
151 | |||||
152 | private function createPrototypeNode(string $name): ArrayNodeDefinition |
||||
153 | { |
||||
154 | return $this->createNode($name) |
||||
155 | ->normalizeKeys(false) |
||||
156 | ->useAttributeAsKey('name'); |
||||
157 | } |
||||
158 | |||||
159 | private function createNode(string $name): ArrayNodeDefinition |
||||
160 | { |
||||
161 | if (\method_exists(TreeBuilder::class, 'getRootNode')) { |
||||
162 | $treeBuilder = new TreeBuilder($name); |
||||
163 | $node = $treeBuilder->getRootNode(); |
||||
164 | } else { |
||||
165 | // BC layer for symfony/config 4.1 and older |
||||
166 | $treeBuilder = new TreeBuilder(); |
||||
167 | $node = $treeBuilder->root($name); |
||||
0 ignored issues
–
show
The function
Symfony\Component\Config...der\TreeBuilder::root() has been deprecated: since Symfony 4.3, pass the root name to the constructor instead
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This function has been deprecated. The supplier of the function has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.
Loading history...
|
|||||
168 | } |
||||
169 | |||||
170 | \assert($node instanceof ArrayNodeDefinition); |
||||
171 | |||||
172 | return $node; |
||||
173 | } |
||||
174 | } |
||||
175 |
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.