Allow serializers to add links#79
Allow serializers to add links#79tobyzerner merged 1 commit intotobyzerner:masterfrom bwaidelich:links-in-resources
Conversation
With this change Serializers can provide links like::
```
class PostSerializer implements SerializerInterface
{
// ...
public function getLinks($post) {
return ['self' => '/posts/' . $post->id];
}
}
```
Partly resolves #64
There was a problem hiding this comment.
Each class must be in a file by itself
There was a problem hiding this comment.
yeah well.. nit pick yourself ;)
There was a problem hiding this comment.
The Resource constructor expects those parameters
|
FYI: This allows serializers to provide link relations (which I think is a crucial feature) partly resolving #64 – if this gets merged I'll gladly add another PR addressing the meta part |
|
I like. Hope this can get merged, as it's come in handy for a couple of my projects. |
There was a problem hiding this comment.
Should a Resource instance's links take precedence over the serializer links?
There was a problem hiding this comment.
That's what I assumed (and what is covered by a test), but frankly I wasn't really sure about it.. And after thinking about it again it might be more flexible if a serializer can overrule resource links.
In the original patch by @bnchdrff it was also the other way around - should I swap it?
There was a problem hiding this comment.
Ah yes, didn't see the test and misread the order of array_merge arguments – the current behaviour is fine.
Allow serializers to add links
With this change Serializers can provide links like::
Partly resolves #64