src/Api/Response/RestResponseBuilder.php
protected function transformContent(TransformContainerInterface $container)
    {
        if (null === $container->getTransformer()) {
            return $container->getContent();
        }

        $transformer = $this->makeTransformerInstance($container->getTransformer());
        $content     = $container->getContent();

        if ($container->isCollection()) {

            // Detect pagination and convert apply it for Fractal
            $paginator   = null;

            if ($content instanceof Paginator) {
                $paginator = $content;
                $content   = $content->items();
            }

            /** @var FractalCollection $resource */
            $resource = new FractalCollection($content, $transformer);

            if ($paginator) {
                $resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
            }

        } else {
            /** @var FractalItem $resource */
            $resource = new FractalItem($content, $transformer);
        }

        return $this->fractalManager->createData($resource)->toArray();
    }
protected function transformContent(TransformContainerInterface $container)
    {
        if (null === $container->getTransformer()) {
            return $container->getContent();
        }

        $transformer = $this->makeTransformerInstance($container->getTransformer());
        $content     = $container->getContent();

        if ($container->isCollection()) {

            // Detect pagination and convert apply it for Fractal
            $paginator   = null;

            if ($content instanceof Paginator) {
                $paginator = $content;
                $content   = $content->items();
            }

            /** @var FractalCollection $resource */
            $resource = new FractalCollection($content, $transformer);

            if ($paginator) {
                $resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
            }

        } else {
            /** @var FractalItem $resource */
            $resource = new FractalItem($content, $transformer);
        }

        return $this->fractalManager->createData($resource)->toArray();
    }
protected function transformContent ( TransformContainerInterface $ container ) { if ( null === $ container -> getTransformer ( ) ) { return $ container -> getContent ( ) ; } $ transformer = $ this -> makeTransformerInstance ( $ container -> getTransformer ( ) ) ; $ content = $ container -> getContent ( ) ; if ( $ container -> isCollection ( ) ) { // Detect pagination and convert apply it for Fractal $ paginator = null ; if ( $ content instanceof Paginator ) { $ paginator = $ content ; $ content = $ content -> items ( ) ; } /** @var FractalCollection $resource */ $ resource = new FractalCollection ( $ content , $ transformer ) ; if ( $ paginator ) { $ resource -> setPaginator ( new IlluminatePaginatorAdapter ( $ paginator ) ) ; } } else { /** @var FractalItem $resource */ $ resource = new FractalItem ( $ content , $ transformer ) ; } return $ this -> fractalManager -> createData ( $ resource ) -> toArray ( ) ; }
Transforms content wrapped in a transform container.

@param TransformContainerInterface $container
@return mixed
Transforms content wrapped in a transform container .