Yeah thats what I’m getting at. :)

Then you can do the same in your controller, and everything should be happy and flexible. We document that they are optional, and its a good idea to set them if you plan on changing formats, but also mention WHY THE HELL WOULD YOU CHANGE FORMATS.

Like those Laravel folks who pretend people are swapping from MySQL to Mongo and back again every other Tuesday. :D

-- 
Phil Sturgeon

On May 6, 2014 at 1:35:47 PM, Jason Lewis (notifications@github.com) wrote:

In src/Serializer/DataArraySerializer.php:

> @@ -0,0 +1,29 @@
> +<?php namespace League\Fractal\Serializer;
> +
> +class DataArraySerializer extends ArraySerializer
> +{
> +
> +    /**
> +     * Serialize the top level data.
> +     *  
> +     * @param array $data
> +     *  
> +     * @return array
> +     */
> +    public function serializeData(array $data)
> +    {
> +        return array('data' => $data);
Yeah that makes sense. So once you have a resource of posts, for example, you'd do something like this.

$resource = new League\Fractal\Resource\Collection($posts, new PostTransformer);
$resource->setResourceKey('posts');
That's what you're getting at, right? And then the JSON API serializer will simply throw a tantrum if there's no key. Because it shouldn't try and guess at the key.

—
Reply to this email directly or view it on GitHub.