如何覆盖实体多元化? [英] How to override entity pluralisation?

查看:33
本文介绍了如何覆盖实体多元化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开始使用 API 平台,它看起来非常棒,但它是一个工具包,而且通常可以在 Google 或 Stack Overflow 上快速搜索答案和我可能遇到的问题.

I've started playing around with API Platform and it's looking like a fantastic but of kit and generally a quick Google or Stack Overflow search answers and questions I might have.

然而,我正在努力解决这个问题,它可能是一个简单的术语问题......

However, this one I'm struggling with and it could be a simple terminology issue...

如何更改或覆盖实体名称的自动复数形式?IE.舰队正在变成舰队.

How do I go about changing or overriding the automatic pluralisation of entity names? I.e. Fleet is becoming Fleets.

关于在哪里查找文档的任何提示或有关如何做我所追求的任何快速示例的任何提示?我正在使用注释.

Any tips on where to look for documentation or any quick examples of how to do what I'm after? I'm using annotations.

提前致谢!

推荐答案

您可以创建不使用 Inflector::pluralize() 的自定义操作路径解析器.

You can create custom Operation Path Resolver which doesn't use Inflector::pluralize().

文档中有关于它的部分(https://api-platform.com/docs/core/operation-path-naming/#create-a-custom-operation-path-resolver).

There is section in docs about it (https://api-platform.com/docs/core/operation-path-naming/#create-a-custom-operation-path-resolver).

它需要创建实现 OperationPathResolverInterface 的自定义类 (https://github.com/api-platform/core/blob/master/src/PathResolver/OperationPathResolverInterface.php)

It requires creating custom class which implements OperationPathResolverInterface (https://github.com/api-platform/core/blob/master/src/PathResolver/OperationPathResolverInterface.php)

这篇关于如何覆盖实体多元化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆