1 | <?php |
||
22 | class TwigNodeDefinition extends ArrayNodeDefinition |
||
23 | { |
||
24 | 9 | public function __construct() |
|
35 | |||
36 | /** |
||
37 | * Configure Twig options. |
||
38 | * |
||
39 | * @return TwigNodeDefinition $this |
||
40 | */ |
||
41 | 9 | private function configureTwigOptions() |
|
42 | { |
||
43 | $this |
||
44 | 9 | ->fixXmlConfig('path') |
|
45 | 9 | ->children() |
|
46 | 9 | ->variableNode('autoescape')->defaultValue(false)->end() |
|
47 | 9 | ->scalarNode('autoescape_service')->defaultNull()->end() |
|
48 | 9 | ->scalarNode('autoescape_service_method')->defaultNull()->end() |
|
49 | 9 | ->scalarNode('base_template_class')->example('Twig_Template')->cannotBeEmpty()->end() |
|
50 | 9 | ->scalarNode('cache')->defaultValue('%kernel.cache_dir%/query_resources/twig')->end() |
|
51 | 9 | ->scalarNode('charset')->defaultValue('%kernel.charset%')->end() |
|
52 | 9 | ->booleanNode('debug')->defaultValue('%kernel.debug%')->end() |
|
53 | 9 | ->booleanNode('strict_variables')->end() |
|
54 | 9 | ->scalarNode('auto_reload')->end() |
|
55 | 9 | ->integerNode('optimizations')->min(-1)->end() |
|
56 | 9 | ->arrayNode('paths') |
|
57 | 9 | ->normalizeKeys(false) |
|
58 | 9 | ->useAttributeAsKey('paths') |
|
59 | 9 | ->beforeNormalization() |
|
60 | 9 | ->always() |
|
61 | ->then(function ($paths) { |
||
62 | 3 | $normalized = array(); |
|
63 | 3 | foreach ($paths as $path => $namespace) { |
|
64 | 3 | if (is_array($namespace)) { |
|
65 | // xml |
||
66 | 1 | $path = $namespace['value']; |
|
67 | 1 | $namespace = $namespace['namespace']; |
|
68 | } |
||
69 | |||
70 | // path within the default namespace |
||
71 | 3 | if (ctype_digit((string) $path)) { |
|
72 | $path = $namespace; |
||
73 | $namespace = null; |
||
74 | } |
||
75 | |||
76 | 3 | $normalized[$path] = $namespace; |
|
77 | } |
||
78 | |||
79 | 3 | return $normalized; |
|
80 | 9 | }) |
|
81 | 9 | ->end() |
|
82 | 9 | ->prototype('variable')->end() |
|
83 | 9 | ->end() |
|
84 | 9 | ->end() |
|
85 | ; |
||
86 | |||
87 | 9 | return $this; |
|
88 | } |
||
89 | |||
90 | /** |
||
91 | * Configure Twig format options. |
||
92 | * |
||
93 | * @return TwigNodeDefinition $this |
||
94 | */ |
||
95 | 9 | private function configureTwigFormatOptions() |
|
125 | |||
126 | /** |
||
127 | * Configure Twig globals. |
||
128 | * |
||
129 | * @return TwigNodeDefinition $this |
||
130 | */ |
||
131 | 9 | private function configureTwigGlobals() |
|
180 | } |
||
181 |