protected function serializeResource(FractalSerializerAbstract $serializer, $data)
    {
        $resourceKey = $this->resource->getResourceKey();

        if ($this->resource instanceof FractalCollection) {
            return $serializer->collection($resourceKey, $data);
        } elseif ($this->resource instanceof FractalItem) {
            return $serializer->item($resourceKey, $data);
        } elseif ($this->resource instanceof NodesResourceContent) {
            return (! empty($resourceKey)) ? [$resourceKey => $data] : $data;
        }

        return $serializer->null();
    }
protected function serializeResource(FractalSerializerAbstract $serializer, $data)
    {
        $resourceKey = $this->resource->getResourceKey();

        if ($this->resource instanceof FractalCollection) {
            return $serializer->collection($resourceKey, $data);
        } elseif ($this->resource instanceof FractalItem) {
            return $serializer->item($resourceKey, $data);
        } elseif ($this->resource instanceof NodesResourceContent) {
            return (! empty($resourceKey)) ? [$resourceKey => $data] : $data;
        }

        return $serializer->null();
    }
protected function serializeResource ( FractalSerializerAbstract $ serializer , $ data ) { $ resourceKey = $ this -> resource -> getResourceKey ( ) ; if ( $ this -> resource instanceof FractalCollection ) { return $ serializer -> collection ( $ resourceKey , $ data ) ; } elseif ( $ this -> resource instanceof FractalItem ) { return $ serializer -> item ( $ resourceKey , $ data ) ; } elseif ( $ this -> resource instanceof NodesResourceContent ) { return ( ! empty ( $ resourceKey ) ) ? [ $ resourceKey => $ data ] : $ data ; } return $ serializer -> null ( ) ; }
Serialize a resource.

@author Morten Rugaard <moru@nodes.dk>

@param  \League\Fractal\Serializer\SerializerAbstract $serializer
@param  mixed                                         $data
@return array
Serialize a resource .