/** * @inheritdoc */ public function item(array $data, TransformerAbstract $transformer) { $resource = array('id' => $data['id'], 'type' => $transformer->getTypeKey(), 'attributes' => $data); unset($resource['attributes']['id']); foreach (array_keys($transformer->getRelationships()) as $relationship) { unset($resource['attributes'][$relationship]); } return $resource; }
/** * Returns an array of relationships that should be sideloaded. * * @param boolean $group * @return array */ public function sideloadResources($group = true) { $resources = array(); foreach ($this->transformer->getIncludedResources() as $key => $resource) { if ($resource instanceof ResourceAbstract) { $data = $resource->create($this->serializer); if ($group) { $resources[!is_numeric($key) ? $key : $resource] = $data; } else { if ($resource->returnsCollection()) { $resources = array_merge($resources, $data); } else { $resources[] = $data; } } } else { } } return $resources; }