transformToResource() public method

public transformToResource ( Transformation $transformation, mixed $domainObject ) : array
$transformation Transformation
$domainObject mixed
return array
Esempio n. 1
0
 /**
  * @param \WoohooLabs\Yin\JsonApi\Transformer\Transformation $transformation
  * @param mixed $domainObject
  * @param string $relationshipName
  * @param array $defaultRelationships
  * @return array
  */
 protected function transformResource(Transformation $transformation, $domainObject, $relationshipName, array $defaultRelationships)
 {
     if ($transformation->request->isIncludedRelationship($transformation->basePath, $relationshipName, $defaultRelationships)) {
         $transformation->data->addIncludedResource($this->resourceTransformer->transformToResource($transformation, $domainObject));
     }
     return $this->resourceTransformer->transformToResourceIdentifier($domainObject);
 }
 /**
  * @inheritDoc
  */
 protected function fillData(Transformation $transformation)
 {
     $transformation->data->addPrimaryResource($this->transformer->transformToResource($transformation, $this->domainObject));
 }
 /**
  * @inheritDoc
  */
 protected function fillData(Transformation $transformation)
 {
     foreach ($this->getItems() as $item) {
         $transformation->data->addPrimaryResource($this->transformer->transformToResource($transformation, $item));
     }
 }