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.
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.