浏览代码

[FrameworkBundle] fixed TemplateRefence::getPath() when using namespaced controllers (i.e: AcmeBlogBundle\\Controller\\Admin\\PostController)

Hugo Hamon 14 年之前
父节点
当前提交
2616efb03f
共有 1 个文件被更改,包括 6 次插入0 次删除
  1. 6 0
      src/Symfony/Bundle/FrameworkBundle/Templating/TemplateReference.php

+ 6 - 0
src/Symfony/Bundle/FrameworkBundle/Templating/TemplateReference.php

@@ -41,6 +41,12 @@ class TemplateReference extends BaseTemplateReference
     public function getPath()
     {
         $controller = $this->get('controller');
+
+        // Fix for namespaced controllers
+        if (!empty($controller) && false !== strpos($controller, '\\')) {
+            $controller = str_replace('\\', '/', $controller);
+        }
+
         $path = (empty($controller) ? '' : $controller.'/').$this->get('name').'.'.$this->get('format').'.'.$this->get('engine');
 
         return empty($this->parameters['bundle']) ? 'views/'.$path : '@'.$this->get('bundle').'/Resources/views/'.$path;