douhuai2861 2015-12-14 12:01
浏览 24
已采纳

Zend Framework 2&Apigility - 将链接插入集合

I have an Apigility resource with a patchList method. The method returns a collection. I need to set a link to another resource on the returned collection.

So, if a collection looks like this:

{
  _links: {
    self: '//foo.bar',
  },
  _embedded: {
    foo: []
  }    
}

I want it to be like so:

{
  _links: {
    self: '//foo.bar',
    bar: '//foo.bar/456'
  },
  _embedded: {
    foo: []
  }    
}

Now, I have read the docs, and I see how I can add a static link, but I need the link to be set dynamically. I think I might be able to achieve this by listening to the renderCollection event, but I was wondering if there is a simpler solution.

  • 写回答

1条回答 默认 最新

  • dousendun8411 2015-12-15 08:41
    关注

    For single resources you can also use the EntityExtractor to add custom links to the LinkCollection, but for rendering a Collection such an extractor is not used so all you can do to add them dyamically is by using the renderCollection event like you already suggested in your question.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料