Symfony 5.1 - 在呈现模板期间抛出异常("The controller for URI "/_fragment" 不可调用")

Symfony 5.1 - An exception has been thrown during the rendering of a template ("The controller for URI "/_fragment" is not callable")

最近我将我的 symfony 项目 (4.1) 更新到 5.1,但是当我尝试将控制器嵌入到 twig 模板中时我的代码抛出错误:

模板呈现期间抛出异常(“URI“/_fragment”的控制器不可调用:控制器“SamAngularBundle:System:connectionInfo”既不作为服务存在,也不作为class.").

但是当我 运行 时 URL 工作正常: View screenshot

控制器代码:

class SystemController extends \Symfony\Bundle\FrameworkBundle\Controller\AbstractController  {
   /**
    * @Route("/angular/connection/info", name="url_angular_connection_info")
    */
   public function connectionInfoAction() {
       return $this->render("@SamAngular/System/connection_info.html.twig");
   }
}

模板代码:

{# empty Twig template #}
<div class="template-foot">    
    {{render(controller('SamAngularBundle:System:connectionInfo'))}}
</div>

有什么问题?

Bundle:controller:action 语法是 deprecated in 4.1 and removed in 5.0. It's been replaced by the controller::action syntax

同样的模板语法也是dropped much earlier(为了完整性而引用,您已经在使用新的模板语法)。