Exemplo n.º 1
0
 /**
  * Fire the main transformer.
  *
  * @internal
  *
  * @param TransformerAbstract|callable $transformer
  * @param mixed                        $data
  *
  * @return array
  */
 protected function fireTransformer($transformer, $data)
 {
     $includedData = array();
     if (is_callable($transformer)) {
         $transformedData = call_user_func($transformer, $data);
     } else {
         $transformedData = $transformer->transform($data);
     }
     if ($this->transformerHasIncludes($transformer)) {
         $includedData = $this->fireIncludedTransformers($transformer, $data);
         $transformedData = $this->manager->getSerializer()->mergeIncludes($transformedData, $includedData);
     }
     return array($transformedData, $includedData);
 }
Exemplo n.º 2
0
 /**
  * Fire the main transformer.
  *
  * @internal
  *
  * @param TransformerAbstract|callable $transformer
  * @param mixed                        $data
  *
  * @return array
  */
 protected function fireTransformer($transformer, $data)
 {
     $includedData = array();
     if (is_callable($transformer)) {
         $transformedData = call_user_func($transformer, $data);
     } else {
         $transformedData = $transformer->transform($data);
     }
     if ($this->transformerHasIncludes($transformer)) {
         $includedData = $this->fireIncludedTransformers($transformer, $data);
         // If the serializer does not want the includes to be side-loaded then
         // the included data must be merged with the transformed data.
         if (!$this->manager->getSerializer()->sideloadIncludes()) {
             $transformedData = array_merge($transformedData, $includedData);
         }
     }
     return array($transformedData, $includedData);
 }
Exemplo n.º 3
0
 /**
  * Calculate the resourceKey.
  * If configured serializer is not an instance of JsonApiSerializer
  * the resourceKey is useless and null will be returned
  *
  * @param string $resourceKey
  * @return string|null
  */
 private function getResourceKey($resourceKey)
 {
     return $this->fractal->getSerializer() instanceof JsonApiSerializer ? $resourceKey : null;
 }