繁体   English   中英

Symfony 4 - 仅 Profiler 中的 @ParamConverter 注释找不到对象

[英]Symfony 4 - Object not found by the @ParamConverter annotation in Profiler only

该问题仅出现在调试工具栏中。

这是我怀疑导致问题的代码

/**
   * @Route("/{category_slug}/{slug}", name="content_show")
   * @ParamConverter("content", options={"mapping": {"slug": "slug"}})
   * @ParamConverter("category", options={"mapping": {"category_slug": "slug"}})
   * @Method("GET")
   */
  public function show(Category $category, Content $content): Response
  {
    $contents = $category->getContents();
    return $this->render('content/show.html.twig', array(
      'category' => $category,
      'list' => $contents,
      'content' => $content,
    ));
  }

它是唯一带有 ParamConverter 的部分,也是错误前唯一修改的部分。

页面显示正常,一切都找到了,调试工具栏不再工作的错误消息:

An error occurred while loading the web debug toolbar. Open the web profiler.

里面:

App\Entity\Content object not found by the @ParamConverter annotation.

使用 NotFoundHttpException

我清除了缓存,没有任何变化。 代码仍然有效,但没有工具栏是痛苦的,我无法弄清楚是什么导致了这个..

我尝试使用其他注释,例如:

  /**
    * @Route("/{category_slug}/{slug}", name="content_show")
    * @ParamConverter("category", class="App\Entity\Category", options={"mapping": {"category_slug": "slug"}})
    * @Method("GET")
    */

等等。唯一的区别是,如果我从 paramconverter 中删除内容,它仍然有效,但错误在类别上。

提前致谢。

编辑:PHP 7.1.9
作曲家 json :

"require": {
    "php": "^7.1.3",
    "ext-iconv": "*",
    "sensio/framework-extra-bundle": "^5.1",
    "symfony/apache-pack": "^1.0",
    "symfony/console": "^4.0",
    "symfony/expression-language": "^4.0",
    "symfony/flex": "^1.0",
    "symfony/form": "^4.0",
    "symfony/framework-bundle": "^4.0",
    "symfony/lts": "^4@dev",
    "symfony/maker-bundle": "^1.0",
    "symfony/orm-pack": "^1.0",
    "symfony/security-bundle": "^4.0",
    "symfony/security-csrf": "^4.0",
    "symfony/twig-bundle": "^4.0",
    "symfony/validator": "^4.0",
    "symfony/yaml": "^4.0",
    "vich/uploader-bundle": "^1.8"
},
"require-dev": {
    "symfony/dotenv": "^4.0",
    "symfony/profiler-pack": "^1.0",
    "symfony/web-server-bundle": "^4.0"
},

我在网上看到了很多与你的错误相关的错误,我也遇到了,我使用的是 CRUD,我的 url 与之前的路由之一匹配。

我只是发现这个命令php bin/console router:match url通过给我它使用的路由以及它如何php bin/console router:match url帮助我。 我认为这真的很有用,应该分享。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM