/**
  * @param $entityname
  * @return BaseTransformer
  * @throws \Exception
  */
 public function getTransformer($entityname = null)
 {
     if (!$this->transformer || $entityname !== null && $this->transformer->getCurrentResourceKey() !== $entityname) {
         if (null === $entityname) {
             throw new \Exception('transformer is empty, specify the entity name into the parameter');
         }
         $this->transformer = $this->transformerResolver->resolve($entityname);
     }
     return $this->transformer;
 }
Example #2
0
 /**
  * @param $embed
  * @param $parentObject
  * @param $version
  *
  * @return array
  * @throws \Exception
  */
 protected function getEmbedData($embed, $parentObject, $version = "v2")
 {
     $transformer = $this->transformerResolver->resolve($embed);
     $transformer = $this->initTransformer($transformer);
     return [$transformer->getCurrentResourceKey() => $this->getTransformerData($transformer, $parentObject, $version)];
 }