Explorar o código

[TwigBundle] fixed option management for Twig_Environment

Fabien Potencier %!s(int64=14) %!d(string=hai) anos
pai
achega
547eaa81f7

+ 8 - 2
src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php

@@ -35,15 +35,21 @@ class TwigExtension extends Extension
             $loader->load('twig.xml');
         }
 
-        $container->setParameter('twig.options', array_replace($container->getParameter('twig.options'), $config));
-
         // form resources
         foreach (array('resources', 'resource') as $key) {
             if (isset($config['form'][$key])) {
                 $resources = (array) $config['form'][$key];
                 $container->setParameter('twig.form.resources', array_merge($container->getParameter('twig.form.resources'), $resources));
+                unset($config['form'][$key]);
             }
         }
+
+        // convert - to _
+        foreach ($config as $key => $value) {
+            $config[str_replace('-', '_', $key)] = $value;
+        }
+
+        $container->setParameter('twig.options', array_replace($container->getParameter('twig.options'), $config));
     }
 
     /**

+ 3 - 3
src/Symfony/Bundle/TwigBundle/Resources/config/schema/twig-1.0.xsd

@@ -15,9 +15,9 @@
         <xsd:attribute name="charset" type="xsd:string" />
         <xsd:attribute name="debug" type="xsd:string" />
         <xsd:attribute name="cache" type="xsd:string" />
-        <xsd:attribute name="trim_blocks" type="xsd:string" />
-        <xsd:attribute name="auto_reload" type="xsd:string" />
-        <xsd:attribute name="base_template_class" type="xsd:string" />
+        <xsd:attribute name="strict-variables" type="xsd:string" />
+        <xsd:attribute name="auto-reload" type="xsd:string" />
+        <xsd:attribute name="base-template-class" type="xsd:string" />
     </xsd:complexType>
 
     <xsd:complexType name="form">