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

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

问题描述

我已经开始使用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天全站免登陆