php - FosRestBundle 单个数组和可选的关联数组
问题描述
我有一个关于@FOSRest\RequestParam
. 我如何提供可选选项来请求批量更改。
例如:
$postValue = [
'record_id' => 1234,
'content' => "test",
'ttl' => 0,
'prio' => 0,
];
VS
$postValue = [
[
'record_id' => 1234,
'content' => "test",
'ttl' => 0,
'prio' => 0,
],
[
'record_id' => 1234,
'content' => "test",
'ttl' => 0,
'prio' => 0,
]
];
RequestParam 设置如下:
* @FOSRest\RequestParam(name="record_id", allowBlank=false, requirements={"rule" = "\d+", "error_message" = "record_id must be an integer"}, strict=true, nullable=false, description="Record id")
* @FOSRest\RequestParam(name="content", allowBlank=true, default="", description="Content")
* @FOSRest\RequestParam(name="ttl", allowBlank=true, requirements={"rule" = "\d+", "error_message" = "ttl must be an integer"}, default={}, description="Time to live")
* @FOSRest\RequestParam(name="priority", allowBlank=true, requirements={"rule" = "\d+", "error_message" = "priority must be an integer"}, default={}, description="Priority")
我知道使用 amap=true
可以用于第二个示例。但是有没有办法检查使用了两个示例中的哪一个并根据数组的类型获取参数?
我可以解决这个问题,Request $request
但这是我的最后一个解决方案。
希望你们知道一个解决方案:)
解决方案
推荐阅读
- c - 结构数据的 C 内存分配顺序
- java - Java绘图(初级)
- node.js - 从多页应用程序进行身份验证后,如何在初始下载期间将 JWT 令牌加载到 React?
- javascript - Monoidal List的功能链如何存储数据?
- rust - 处理可能是驱动器号或连接到其他东西的路径的路径的正确方法是什么?
- amazon-web-services - 使用 AWS S3 共享文件夹
- regex - 有问题识别数字模式
- node.js - 将不和谐机器人扩展到潜在的 10 万以上并发用户
- jvm - 操作系统内存不足时的 JVM 行为
- c++ - vim 使用户定义类型的颜色与 C++ 中的基本类型相同