src/Tools/ResponseStrategies/TransformerTagsStrategy.php
protected function getTransformerResponse(array $tags)
    {
        try {
            if (empty($transformerTag = $this->getTransformerTag($tags))) {
                return;
            }

            $transformer = $this->getTransformerClass($transformerTag);
            $model = $this->getClassToBeTransformed($tags, (new ReflectionClass($transformer))->getMethod('transform'));
            $modelInstance = $this->instantiateTransformerModel($model);

            $fractal = new Manager();

            if (! is_null(config('apidoc.fractal.serializer'))) {
                $fractal->setSerializer(app(config('apidoc.fractal.serializer')));
            }

            $resource = (strtolower($transformerTag->getName()) == 'transformercollection')
                ? new Collection([$modelInstance, $modelInstance], new $transformer)
                : new Item($modelInstance, new $transformer);

            return [response($fractal->createData($resource)->toJson())];
        } catch (\Exception $e) {
            return;
        }
    }
protected function getTransformerResponse(array $tags)
    {
        try {
            if (empty($transformerTag = $this->getTransformerTag($tags))) {
                return;
            }

            $transformer = $this->getTransformerClass($transformerTag);
            $model = $this->getClassToBeTransformed($tags, (new ReflectionClass($transformer))->getMethod('transform'));
            $modelInstance = $this->instantiateTransformerModel($model);

            $fractal = new Manager();

            if (! is_null(config('apidoc.fractal.serializer'))) {
                $fractal->setSerializer(app(config('apidoc.fractal.serializer')));
            }

            $resource = (strtolower($transformerTag->getName()) == 'transformercollection')
                ? new Collection([$modelInstance, $modelInstance], new $transformer)
                : new Item($modelInstance, new $transformer);

            return [response($fractal->createData($resource)->toJson())];
        } catch (\Exception $e) {
            return;
        }
    }
protected function getTransformerResponse ( array $ tags ) { try { if ( empty ( $ transformerTag = $ this -> getTransformerTag ( $ tags ) ) ) { return ; } $ transformer = $ this -> getTransformerClass ( $ transformerTag ) ; $ model = $ this -> getClassToBeTransformed ( $ tags , ( new ReflectionClass ( $ transformer ) ) -> getMethod ( 'transform' ) ) ; $ modelInstance = $ this -> instantiateTransformerModel ( $ model ) ; $ fractal = new Manager ( ) ; if ( ! is_null ( config ( 'apidoc.fractal.serializer' ) ) ) { $ fractal -> setSerializer ( app ( config ( 'apidoc.fractal.serializer' ) ) ) ; } $ resource = ( strtolower ( $ transformerTag -> getName ( ) ) == 'transformercollection' ) ? new Collection ( [ $ modelInstance , $ modelInstance ] , new $ transformer ) : new Item ( $ modelInstance , new $ transformer ) ; return [ response ( $ fractal -> createData ( $ resource ) -> toJson ( ) ) ] ; } catch ( \ Exception $ e ) { return ; } }
Get a response from the transformer tags.

@param array $tags

@return array|null
Get a response from the transformer tags .