shopware - 重定向到控制器抛出“不幸的是,出了点问题。”
问题描述
我已经在开发模板中安装了这个插件https://github.com/shopware/swag-docs-storefront-controller但是当我运行它并尝试清除购物车时,它重定向到 url 并显示错误“不幸的是,出了点问题。 "
在日志中我发现以下错误
request.CRITICAL:未捕获的 PHP 异常 Shopware\Core\Framework\Routing\Exception\InvalidRouteScopeException:“路由 frontend.checkout.clearCart 的路由范围无效。” 在 /var/www/html/shopware6/vendor/shopware/platform/src/Core/Framework/Routing/RouteScopeListener.php 第 93 行 {"exception":"[object] (Shopware\Core\Framework\Routing\Exception\InvalidRouteScopeException (代码:0):路由frontend.checkout.clearCart的路由范围无效。位于/var/www/html/shopware6/vendor/shopware/platform/src/Core/Framework/Routing/RouteScopeListener.php:93)“} [ ]
但是,这在安装程序设置中工作正常。
解决方案
您需要向控制器添加路由范围。从几周前开始这是强制性的,但似乎示例并未根据此更改。
将 routescope-annotation 添加到控制器就足够了: https ://github.com/shopware/swag-docs-storefront-controller/blob/master/src/Storefront/Controller/ClearCartController.php#L23
只需将其添加到注释中:
* @RouteScope(scopes={"storefront"})
并添加路由范围:
use Shopware\Core\Framework\Routing\Annotation\RouteScope;
我将准备一个可以修复它的拉取请求。
推荐阅读
- amazon-web-services - AWS CloudWatch 代理未启动
- c++ - 是否可以在 gcc/g++ 中强制链接器错误?
- css - 调整窗口大小时,如何使 div 标签内的图像响应?
- javascript - 根据选择值/月/年更改日期
- terraform - 如何使用 terraform 重新启动 EC2 实例而不破坏它们?
- php - 无法创建全天 .ics 事件
- java - 从 CSV 文件读取数据时遇到问题
- javascript - 当我尝试使用``` ...```装饰器不起作用
- c# - CORS 在 ASP.NET-Core-Application 中不起作用
- scala - 将字符串转换为 Apache Avro GenericRecord