Sfoglia il codice sorgente

[FrameworkBundle] fixed template name parsing for namespaced bundles

Fabien Potencier 14 anni fa
parent
commit
102491b9b8

+ 2 - 1
src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php

@@ -77,7 +77,8 @@ class TemplateNameParser extends BaseTemplateNameParser
             ),
             $defaults,
             array(
-                'bundle'     => $bundle,
+                // bundle is used as part of the template path, so we need /
+                'bundle'     => str_replace('\\', '/', $bundle),
                 'controller' => $parts[1],
             )
         );

+ 2 - 2
src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php

@@ -35,8 +35,8 @@ class TemplateNameParserTest extends TestCase
             array('FooBundle:Post:index.php.html', array('index', array('bundle' => 'FooBundle', 'controller' => 'Post', 'renderer' => 'php', 'format' => 'html'))),
             array('FooBundle:Post:index.twig.html', array('index', array('bundle' => 'FooBundle', 'controller' => 'Post', 'renderer' => 'twig', 'format' => 'html'))),
             array('FooBundle:Post:index.php.xml', array('index', array('bundle' => 'FooBundle', 'controller' => 'Post', 'renderer' => 'php', 'format' => 'xml'))),
-            array('SensioFooBundle:Post:index.php.html', array('index', array('bundle' => 'Sensio\\FooBundle', 'controller' => 'Post', 'renderer' => 'php', 'format' => 'html'))),
-            array('SensioCmsFooBundle:Post:index.php.html', array('index', array('bundle' => 'Sensio\\Cms\\FooBundle', 'controller' => 'Post', 'renderer' => 'php', 'format' => 'html'))),
+            array('SensioFooBundle:Post:index.php.html', array('index', array('bundle' => 'Sensio/FooBundle', 'controller' => 'Post', 'renderer' => 'php', 'format' => 'html'))),
+            array('SensioCmsFooBundle:Post:index.php.html', array('index', array('bundle' => 'Sensio/Cms/FooBundle', 'controller' => 'Post', 'renderer' => 'php', 'format' => 'html'))),
             array(':Post:index.php.html', array('index', array('bundle' => '', 'controller' => 'Post', 'renderer' => 'php', 'format' => 'html'))),
             array('::index.php.html', array('index', array('bundle' => '', 'controller' => '', 'renderer' => 'php', 'format' => 'html'))),
         );