plugin/slideshow/Serializer/SlideshowSerializer.php
public function serialize(Slideshow $slideshow)
    {
        return [
            'id' => $slideshow->getUuid(),
            'autoPlay' => $slideshow->getAutoPlay(),
            'interval' => $slideshow->getInterval(),
            'display' => [
                'description' => $slideshow->getDescription(),
                'showOverview' => $slideshow->getShowOverview(),
                'showControls' => $slideshow->getShowControls(),
            ],
            'slides' => array_map(function (Slide $slide) {
                $content = null;
                // TODO : enhance to allow more than files
                if (!empty($slide->getContent())) {
                    /** @var PublicFile $file */
                    $file = $this->om
                        ->getRepository(PublicFile::class)
                        ->findOneBy(['url' => $slide->getContent()]);

                    if ($file) {
                        $content = $this->fileSerializer->serialize($file);
                    }
                }

                return [
                    'id' => $slide->getUuid(),
                    'content' => $content,
                    'meta' => [
                        'title' => $slide->getTitle(),
                        'description' => $slide->getDescription(),
                    ],
                ];
            }, $slideshow->getSlides()->toArray()),
        ];
    }
public function serialize(Slideshow $slideshow)
    {
        return [
            'id' => $slideshow->getUuid(),
            'autoPlay' => $slideshow->getAutoPlay(),
            'interval' => $slideshow->getInterval(),
            'display' => [
                'description' => $slideshow->getDescription(),
                'showOverview' => $slideshow->getShowOverview(),
                'showControls' => $slideshow->getShowControls(),
            ],
            'slides' => array_map(function (Slide $slide) {
                $content = null;
                // TODO : enhance to allow more than files
                if (!empty($slide->getContent())) {
                    /** @var PublicFile $file */
                    $file = $this->om
                        ->getRepository(PublicFile::class)
                        ->findOneBy(['url' => $slide->getContent()]);

                    if ($file) {
                        $content = $this->fileSerializer->serialize($file);
                    }
                }

                return [
                    'id' => $slide->getUuid(),
                    'content' => $content,
                    'meta' => [
                        'title' => $slide->getTitle(),
                        'description' => $slide->getDescription(),
                    ],
                ];
            }, $slideshow->getSlides()->toArray()),
        ];
    }
public function serialize ( Slideshow $ slideshow ) { return [ 'id' => $ slideshow -> getUuid ( ) , 'autoPlay' => $ slideshow -> getAutoPlay ( ) , 'interval' => $ slideshow -> getInterval ( ) , 'display' => [ 'description' => $ slideshow -> getDescription ( ) , 'showOverview' => $ slideshow -> getShowOverview ( ) , 'showControls' => $ slideshow -> getShowControls ( ) , ] , 'slides' => array_map ( function ( Slide $ slide ) { $ content = null ; // TODO : enhance to allow more than files if ( ! empty ( $ slide -> getContent ( ) ) ) { /** @var PublicFile $file */ $ file = $ this -> om -> getRepository ( PublicFile :: class ) -> findOneBy ( [ 'url' => $ slide -> getContent ( ) ] ) ; if ( $ file ) { $ content = $ this -> fileSerializer -> serialize ( $ file ) ; } } return [ 'id' => $ slide -> getUuid ( ) , 'content' => $ content , 'meta' => [ 'title' => $ slide -> getTitle ( ) , 'description' => $ slide -> getDescription ( ) , ] , ] ; } , $ slideshow -> getSlides ( ) -> toArray ( ) ) , ] ; }
Serializes a Slideshow entity for the JSON api.

@param Slideshow $slideshow

@return array
Serializes a Slideshow entity for the JSON api .