php - Api-platform (Symfony) : 将数据添加到 Url
问题描述
我遇到了 Api 平台的问题,我开始工作时已经存在的一些代码让我很生气。这里是 :
/**
* Class PhysicalProfile.
*
* @ORM\Table(name="front_user_physical_profile")
* @ORM\Entity(repositoryClass="App\Repository\PhysicalProfileRepository")
* @ApiResource(
* denormalizationContext={"groups"={"update"}},
* collectionOperations={"create"={
* "method"="POST",
* "path"="/physical-profile",
* "access_control"="is_granted('ROLE_USER')"
* }, "whoami"={"route_name"="api_security_physicalprofile_whoami"}
* },
* itemOperations={
* "get"={"access_control"="is_granted('ROLE_USER')", "normalizationContext"={"groups"={"null"}}},
* }
* )
* @ORM\HasLifecycleCallbacks()
*/
我想做的事情是在查询中传递一个元素,如下所示:
/physical-profile/{store}
然后在我的代码中使用它。
除了我在 Api-platform 的文档中没有找到任何帮助,这让我想知道我想要的是否可能。这就是我来这里的原因,想弄清楚是否有人知道这是否可能,以及如何去做。谢谢 !
编辑: store 不是一个 id 而是一个字符串
解决方案
API 平台期望在/physical-profile/{store}
最后一部分的补丁中是实体 ID。
如果您需要查询某些项目,请使用过滤器。
推荐阅读
- amazon-cognito - 如何将 Cognito(联合)身份 ID 映射到 Cognito 用户池 ID?
- python - 从 JSONS 列表中提取数据的问题
- c# - c#,winforms中如何将手机摄像头或其他摄像头连接到图片框?
- c++11 - libxl 库在 C++ 中的使用
- jquery - 为什么鼠标悬停和鼠标悬停时动画不会重复
- node.js - AWS lambda 调用 Facebook SDK 失败
- ruby-on-rails - 识别升序和降序或范围
- reporting-services - SSRS 参数的日期选择器(日历图标)未显示在 Microsoft Edge 中
- gridview - 如何从 Xamarin 表单应用程序中的 GridView 获取所选项目
- angular - 如何在测试套件中模拟和监视命名空间?