src/Offer/ReadModel/JSONLD/OfferLDProjector.php
protected function applyImageAdded(AbstractImageAdded $imageAdded)
    {
        $document = $this->loadDocumentFromRepository($imageAdded);

        $offerLd = $document->getBody();
        $offerLd->mediaObject = isset($offerLd->mediaObject) ? $offerLd->mediaObject : [];

        $imageData = $this->mediaObjectSerializer
            ->serialize($imageAdded->getImage(), 'json-ld');
        $offerLd->mediaObject[] = $imageData;

        if (count($offerLd->mediaObject) === 1) {
            $offerLd->image = $imageData['contentUrl'];
        }

        return $document->withBody($offerLd);
    }
protected function applyImageAdded(AbstractImageAdded $imageAdded)
    {
        $document = $this->loadDocumentFromRepository($imageAdded);

        $offerLd = $document->getBody();
        $offerLd->mediaObject = isset($offerLd->mediaObject) ? $offerLd->mediaObject : [];

        $imageData = $this->mediaObjectSerializer
            ->serialize($imageAdded->getImage(), 'json-ld');
        $offerLd->mediaObject[] = $imageData;

        if (count($offerLd->mediaObject) === 1) {
            $offerLd->image = $imageData['contentUrl'];
        }

        return $document->withBody($offerLd);
    }
protected function applyImageAdded ( AbstractImageAdded $ imageAdded ) { $ document = $ this -> loadDocumentFromRepository ( $ imageAdded ) ; $ offerLd = $ document -> getBody ( ) ; $ offerLd -> mediaObject = isset ( $ offerLd -> mediaObject ) ? $ offerLd -> mediaObject : [ ] ; $ imageData = $ this -> mediaObjectSerializer -> serialize ( $ imageAdded -> getImage ( ) , 'json-ld' ) ; $ offerLd -> mediaObject [ ] = $ imageData ; if ( count ( $ offerLd -> mediaObject ) === 1 ) { $ offerLd -> image = $ imageData [ 'contentUrl' ] ; } return $ document -> withBody ( $ offerLd ) ; }
Apply the imageAdded event to the item repository.

@param AbstractImageAdded $imageAdded
@return JsonDocument
Apply the imageAdded event to the item repository .