src/Offer/ReadModel/JSONLD/OfferLDProjector.php
protected function applyImageUpdated(AbstractImageUpdated $imageUpdated)
    {
        $document = $this->loadDocumentFromRepository($imageUpdated);

        $offerLd = $document->getBody();

        if (!isset($offerLd->mediaObject)) {
            throw new \Exception('The image to update could not be found.');
        }

        $updatedMediaObjects = [];

        foreach ($offerLd->mediaObject as $mediaObject) {
            $mediaObjectMatches = (
                strpos(
                    $mediaObject->{'@id'},
                    (string)$imageUpdated->getMediaObjectId()
                ) > 0
            );

            if ($mediaObjectMatches) {
                $mediaObject->description = (string)$imageUpdated->getDescription();
                $mediaObject->copyrightHolder = (string)$imageUpdated->getCopyrightHolder();

                $updatedMediaObjects[] = $mediaObject;
            }
        };

        if (empty($updatedMediaObjects)) {
            throw new \Exception('The image to update could not be found.');
        }

        return $document->withBody($offerLd);
    }
protected function applyImageUpdated(AbstractImageUpdated $imageUpdated)
    {
        $document = $this->loadDocumentFromRepository($imageUpdated);

        $offerLd = $document->getBody();

        if (!isset($offerLd->mediaObject)) {
            throw new \Exception('The image to update could not be found.');
        }

        $updatedMediaObjects = [];

        foreach ($offerLd->mediaObject as $mediaObject) {
            $mediaObjectMatches = (
                strpos(
                    $mediaObject->{'@id'},
                    (string)$imageUpdated->getMediaObjectId()
                ) > 0
            );

            if ($mediaObjectMatches) {
                $mediaObject->description = (string)$imageUpdated->getDescription();
                $mediaObject->copyrightHolder = (string)$imageUpdated->getCopyrightHolder();

                $updatedMediaObjects[] = $mediaObject;
            }
        };

        if (empty($updatedMediaObjects)) {
            throw new \Exception('The image to update could not be found.');
        }

        return $document->withBody($offerLd);
    }
protected function applyImageUpdated ( AbstractImageUpdated $ imageUpdated ) { $ document = $ this -> loadDocumentFromRepository ( $ imageUpdated ) ; $ offerLd = $ document -> getBody ( ) ; if ( ! isset ( $ offerLd -> mediaObject ) ) { throw new \ Exception ( 'The image to update could not be found.' ) ; } $ updatedMediaObjects = [ ] ; foreach ( $ offerLd -> mediaObject as $ mediaObject ) { $ mediaObjectMatches = ( strpos ( $ mediaObject -> { '@id' } , ( string ) $ imageUpdated -> getMediaObjectId ( ) ) > 0 ) ; if ( $ mediaObjectMatches ) { $ mediaObject -> description = ( string ) $ imageUpdated -> getDescription ( ) ; $ mediaObject -> copyrightHolder = ( string ) $ imageUpdated -> getCopyrightHolder ( ) ; $ updatedMediaObjects [ ] = $ mediaObject ; } } ; if ( empty ( $ updatedMediaObjects ) ) { throw new \ Exception ( 'The image to update could not be found.' ) ; } return $ document -> withBody ( $ offerLd ) ; }
Apply the ImageUpdated event to the item repository.

@param AbstractImageUpdated $imageUpdated
@return JsonDocument
@throws \Exception
Apply the ImageUpdated event to the item repository .