简体   繁体   English

Symfony 5.1 - 在渲染模板期间抛出异常(“URI “/_fragment”的控制器不可调用”)

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

recently I update my symfony project (4.1) to 5.1, but my code throws an error when I try embed the controller in twig template:最近我将我的 symfony 项目 (4.1) 更新到 5.1,但是当我尝试将控制器嵌入到 twig 模板中时,我的代码抛出了一个错误:

An exception has been thrown during the rendering of a template ("The controller for URI "/_fragment" is not callable: Controller "SamAngularBundle:System:connectionInfo" does neither exist as service nor as class.").在渲染模板期间抛出异常(“URI“/_fragment”的控制器不可调用:控制器“SamAngularBundle:System:connectionInfo”既不作为服务也不作为类存在。”)。

But when I run the URL works fine: View screenshot但是当我运行 URL 时工作正常:查看屏幕截图

Controller code:控制器代码:

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");
   }
}

Template code:模板代码:

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

What's the problem?有什么问题?

The Bundle:controller:action syntax was deprecated in 4.1 and removed in 5.0. Bundle:controller:action语法在 4.1 中弃用并在 5.0 中被移除。 It's been replaced by the controller::action syntax .它已被controller::action语法取代。

The same syntax for templates was also dropped much earlier (referenced for completeness, you are already using the new template syntax).模板的相同语法也更早删除(为了完整性参考,您已经在使用新的模板语法)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Symfony 错误:“呈现模板期间抛出异常” - Symfony Error: "An exception has been thrown during the rendering of a template" Symfony-呈现模板期间引发了异常 - Symfony - An exception has been thrown during the rendering of a template symfony在渲染模板时抛出了异常 - symfony An exception has been thrown during the rendering of a template 在渲染模板期间抛出异常(“找不到控制器: - An exception has been thrown during the rendering of a template ("Controller not found: Symfony和Doctrine问题&#39;在渲染模板期间引发了异常(“注意:未定义索引:设备”) - Symfony and Doctrine Issue 'An exception has been thrown during the rendering of a template (“Notice: Undefined index: equipe”) Twig在Laravel中报告“在渲染模板期间引发了异常” - Twig reports “An exception has been thrown during the rendering of a template” in Laravel 呈现模板期间引发了异常(“ A __toString()” - An exception has been thrown during the rendering of a template (“A ”__toString()" Symfony:在渲染模板期间引发了异常(“注意:数组到字符串的转换”)。 当我尝试将类别添加到标签时 - Symfony: An exception has been thrown during the rendering of a template (“Notice: Array to string conversion”). when I try to add a class to a label 在渲染模板期间引发了异常(“无法解析依赖项 [Parameter #0 [ $listing ]]”) - An exception has been thrown during the rendering of a template (“Unable to resolve dependency [Parameter #0 [ $listing ]]”) 在呈现模板期间抛出异常(“警告:字符串转换时丢失数据”) - An exception has been thrown during the rendering of a template ("Warning: Loss of data on string conversion")
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM