JsonApiSerializer and $resourceKey
Hello, sorry if this has already been answered but I couldn't find anything related.
For the JSON-API Serializer you need to pass in a $resourceKey.
// Important, notice the Resource Key in the third parameter:
$resource = new Item($book, new JsonApiBookTransformer(), 'books');
But wouldn't a given transformer typically have the same type for it's response? A book would always be of type books. Wouldn't it be better to declare a default type in the transformer?
I ended up writing something to handle exactly this. Essentially, I store a $resourceKey on the Transformer and each transformer defaults to using that. However, the user can still pass a string in via the default implementation to override the Transformer's key.
@dtirer If you are willing, would you make a pull request with that functionality? If not then I'll do it over the weekend.
@willishq sure, I'd be interested. I should be able to do it in the next few days
Any news on this?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 4 weeks if no further activity occurs. Thank you for your contributions.