In raising this pull request, I confirm the following (please check boxes):
[x] I have read and understood the [contributors guide]().
[x] I have checked that another pull request for this purpose does not exist.
[x] I have considered, and confirmed that this submission will be valuable to others.
[x] I accept that this submission may not be used, and the pull request closed at the will of the maintainer.
[x] I give this submission freely, and claim no ownership to its content.
My familiarity with the project is as follows (check one):
[ ] I have never used the project.
[ ] I have used the project briefly.
[x] I have used the project extensively, but have not contributed previously.
[ ] I am an active contributor to the project.
If the project maintainer has any additional requirements, they will be listed here.
No additional requirements.
Makes it easier to override the \EllipseSynergie\ApiResponse\Laravel\ResponseServiceProvider class to change the default serializer.
class OptionalResourceKeyResponseServiceProvider extends ResponseServiceProvider
{
protected function getSerializer()
{
return new OptionalKeySerializer();
}
}
I also changed the default \EllipseSynergie\ApiResponse\Serializer\Serializer so that when RESOURCE_KEY constant is null, it returns the non-nested data as-is.
This helps remove nested data resource keys for each included resource.
In raising this pull request, I confirm the following (please check boxes):
My familiarity with the project is as follows (check one):
If the project maintainer has any additional requirements, they will be listed here.
Makes it easier to override the
\EllipseSynergie\ApiResponse\Laravel\ResponseServiceProvider
class to change the default serializer.I also changed the default
\EllipseSynergie\ApiResponse\Serializer\Serializer
so that whenRESOURCE_KEY
constant isnull
, it returns the non-nested data as-is.This helps remove nested
data
resource keys for each included resource.If you still want to keep the root
data
property to wrap your resource, just specify this within your transformer. (Reference: https://github.com/thephpleague/fractal/issues/299)Or when dealing with includes, specify a resource key when using the response:
All tests are passing as it doesn't change the default behaviour so it's still backward compatible.