Пример #1
0
 /**
  * @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;
 }
Пример #2
0
 /**
  * @param $transformer
  */
 protected function initTransformer(BaseTransformer $transformer)
 {
     $transformer->setCurrentScope($this->currentScope)->setParamRequestEmbed($this->requestEmbed)->setParentEmbed($this->getEmbed());
 }
Пример #3
0
 /**
  * @param BaseTransformer $transformer
  *
  * @return BaseTransformer
  */
 protected function initTransformer(BaseTransformer $transformer)
 {
     $defaultIncludes = [];
     if (in_array('user', $transformer->getAvailableIncludes())) {
         $defaultIncludes[] = 'user';
     }
     $transformer->setDefaultIncludes($defaultIncludes);
     return $transformer;
 }