plugin/slideshow/Serializer/SlideshowSerializer.php
public function deserialize($data, Slideshow $slideshow, array $options = [])
    {
        $this->sipe('autoPlay', 'setAutoPlay', $data, $slideshow);
        $this->sipe('interval', 'setInterval', $data, $slideshow);
        $this->sipe('display.description', 'setDescription', $data, $slideshow);
        $this->sipe('display.showOverview', 'setShowOverview', $data, $slideshow);
        $this->sipe('display.showControls', 'setShowControls', $data, $slideshow);

        if (isset($data['slides'])) {
            // we will remove updated slides from this list
            // remaining ones will be deleted
            $existingSlides = $slideshow->getSlides()->toArray();

            foreach ($data['slides'] as $slideOrder => $slideData) {
                $slide = new Slide();

                /**
                 * check if slide already exists.
                 *
                 * @var int
                 * @var Slide $existing
                 */
                foreach ($existingSlides as $index => $existing) {
                    if (isset($existing) && $existing->getUuid() === $slideData['id']) {
                        // slide found
                        $slide = $existing;
                        unset($existingSlides[$index]);
                        break;
                    }
                }

                $slide->setOrder($slideOrder);

                if (!in_array(Options::REFRESH_UUID, $options)) {
                    $this->sipe('id', 'setUuid', $data, $slideshow);
                }

                $this->sipe('meta.title', 'setTitle', $slideData, $slide);
                $this->sipe('meta.description', 'setDescription', $slideData, $slide);

                // TODO : enhance to allow more than files (eg. HTML)
                $this->sipe('content.url', 'setContent', $slideData, $slide);

                $slideshow->addSlide($slide);
            }

            // Delete slides which no longer exist
            $slidesToDelete = array_values($existingSlides);
            foreach ($slidesToDelete as $toDelete) {
                $slideshow->removeSlide($toDelete);
            }
        }

        return $slideshow;
    }
public function deserialize($data, Slideshow $slideshow, array $options = [])
    {
        $this->sipe('autoPlay', 'setAutoPlay', $data, $slideshow);
        $this->sipe('interval', 'setInterval', $data, $slideshow);
        $this->sipe('display.description', 'setDescription', $data, $slideshow);
        $this->sipe('display.showOverview', 'setShowOverview', $data, $slideshow);
        $this->sipe('display.showControls', 'setShowControls', $data, $slideshow);

        if (isset($data['slides'])) {
            // we will remove updated slides from this list
            // remaining ones will be deleted
            $existingSlides = $slideshow->getSlides()->toArray();

            foreach ($data['slides'] as $slideOrder => $slideData) {
                $slide = new Slide();

                /**
                 * check if slide already exists.
                 *
                 * @var int
                 * @var Slide $existing
                 */
                foreach ($existingSlides as $index => $existing) {
                    if (isset($existing) && $existing->getUuid() === $slideData['id']) {
                        // slide found
                        $slide = $existing;
                        unset($existingSlides[$index]);
                        break;
                    }
                }

                $slide->setOrder($slideOrder);

                if (!in_array(Options::REFRESH_UUID, $options)) {
                    $this->sipe('id', 'setUuid', $data, $slideshow);
                }

                $this->sipe('meta.title', 'setTitle', $slideData, $slide);
                $this->sipe('meta.description', 'setDescription', $slideData, $slide);

                // TODO : enhance to allow more than files (eg. HTML)
                $this->sipe('content.url', 'setContent', $slideData, $slide);

                $slideshow->addSlide($slide);
            }

            // Delete slides which no longer exist
            $slidesToDelete = array_values($existingSlides);
            foreach ($slidesToDelete as $toDelete) {
                $slideshow->removeSlide($toDelete);
            }
        }

        return $slideshow;
    }
public function deserialize ( $ data , Slideshow $ slideshow , array $ options = [ ] ) { $ this -> sipe ( 'autoPlay' , 'setAutoPlay' , $ data , $ slideshow ) ; $ this -> sipe ( 'interval' , 'setInterval' , $ data , $ slideshow ) ; $ this -> sipe ( 'display.description' , 'setDescription' , $ data , $ slideshow ) ; $ this -> sipe ( 'display.showOverview' , 'setShowOverview' , $ data , $ slideshow ) ; $ this -> sipe ( 'display.showControls' , 'setShowControls' , $ data , $ slideshow ) ; if ( isset ( $ data [ 'slides' ] ) ) { // we will remove updated slides from this list // remaining ones will be deleted $ existingSlides = $ slideshow -> getSlides ( ) -> toArray ( ) ; foreach ( $ data [ 'slides' ] as $ slideOrder => $ slideData ) { $ slide = new Slide ( ) ; /**
                 * check if slide already exists.
                 *
                 * @var int
                 * @var Slide $existing
                 */ foreach ( $ existingSlides as $ index => $ existing ) { if ( isset ( $ existing ) && $ existing -> getUuid ( ) === $ slideData [ 'id' ] ) { // slide found $ slide = $ existing ; unset ( $ existingSlides [ $ index ] ) ; break ; } } $ slide -> setOrder ( $ slideOrder ) ; if ( ! in_array ( Options :: REFRESH_UUID , $ options ) ) { $ this -> sipe ( 'id' , 'setUuid' , $ data , $ slideshow ) ; } $ this -> sipe ( 'meta.title' , 'setTitle' , $ slideData , $ slide ) ; $ this -> sipe ( 'meta.description' , 'setDescription' , $ slideData , $ slide ) ; // TODO : enhance to allow more than files (eg. HTML) $ this -> sipe ( 'content.url' , 'setContent' , $ slideData , $ slide ) ; $ slideshow -> addSlide ( $ slide ) ; } // Delete slides which no longer exist $ slidesToDelete = array_values ( $ existingSlides ) ; foreach ( $ slidesToDelete as $ toDelete ) { $ slideshow -> removeSlide ( $ toDelete ) ; } } return $ slideshow ; }
Deserializes Slideshow data into entities.

@param array     $data
@param Slideshow $slideshow

@return Slideshow
Deserializes Slideshow data into entities .