问题描述
我正在使用单一路径格式,并希望按照相同的逻辑生成路由名称,以实现一致性和简化。
这个行为似乎是由 ApiPlatform\Core\Bridge\Symfony\Routing\RouteNameGenerator 处理的
基本上对于我的用例,我只需要在
中将 $pluralize 参数设置为 falseRouteNameGenerator::inflector(string $name,bool $pluralize = true)
但它在调用时从未定义,所有调用都是静态的。 服务覆盖不起作用
//services.yaml
ApiPlatform\Core\Bridge\Symfony\Routing\RouteNameGenerator:
class: App\Operation\RouteNameGenerator
有什么解决办法吗?
解决方法
它不工作(根本没有覆盖),或者它在容器中显示被覆盖,但仍然生成多个路由?我这个你需要覆盖ApiPlatform\Core\Operation\Factory\SubresourceOperationFactory
,因为有像RouteNameGenerator::inflector($operation['property'],$operation['collection'] ?? false)
这样的调用仍然将复数设置为true