【发布时间】:2021-07-09 08:40:42
【问题描述】:
在我的 DashboarController 中,我在 configureMenuItems() 函数中添加了一个指向我的路由之一的链接,如下所示:yield MenuItem::linktoRoute('Title', 'icon', 'my_index', ['key' => 'value']);。
在我的控制器中,我尝试像往常一样访问参数:
/**
* @Route("/my", name="my_")
*/
class OneController extends AbstractController
{
/**
* @Route("/{key}", name="index")
*/
public function index(string $key): Response
{
return $this->render('my_index/index.html.twig', [
'controller_name' => 'OneController',
'key' => 'someKey'
]);
}
}
但我收到错误 No route found for GET /my。不使用参数{key}我可以调用页面。
有人可以帮我如何访问linktoRoute()的参数数组吗?
提前致谢!
更新:
解决方案是:bin/console cache:clear 后跟bin/console cache:warmup 然后你可以找到参数作为 GET-Parameters...
【问题讨论】: