src/Controller/Api/GalleryController.php
public function deleteGalleryMediaGalleryhasmediaAction($galleryId, $mediaId)
    {
        $gallery = $this->getGallery($galleryId);
        $media = $this->getMedia($mediaId);

        foreach ($gallery->getGalleryHasMedias() as $key => $galleryHasMedia) {
            if ($galleryHasMedia->getMedia()->getId() === $media->getId()) {
                $gallery->getGalleryHasMedias()->remove($key);
                $this->getGalleryManager()->save($gallery);

                return ['deleted' => true];
            }
        }

        return FOSRestView::create([
            'error' => sprintf('Gallery "%s" does not have media "%s" associated', $galleryId, $mediaId),
        ], 400);
    }
public function deleteGalleryMediaGalleryhasmediaAction($galleryId, $mediaId)
    {
        $gallery = $this->getGallery($galleryId);
        $media = $this->getMedia($mediaId);

        foreach ($gallery->getGalleryHasMedias() as $key => $galleryHasMedia) {
            if ($galleryHasMedia->getMedia()->getId() === $media->getId()) {
                $gallery->getGalleryHasMedias()->remove($key);
                $this->getGalleryManager()->save($gallery);

                return ['deleted' => true];
            }
        }

        return FOSRestView::create([
            'error' => sprintf('Gallery "%s" does not have media "%s" associated', $galleryId, $mediaId),
        ], 400);
    }
public function deleteGalleryMediaGalleryhasmediaAction ( $ galleryId , $ mediaId ) { $ gallery = $ this -> getGallery ( $ galleryId ) ; $ media = $ this -> getMedia ( $ mediaId ) ; foreach ( $ gallery -> getGalleryHasMedias ( ) as $ key => $ galleryHasMedia ) { if ( $ galleryHasMedia -> getMedia ( ) -> getId ( ) === $ media -> getId ( ) ) { $ gallery -> getGalleryHasMedias ( ) -> remove ( $ key ) ; $ this -> getGalleryManager ( ) -> save ( $ gallery ) ; return [ 'deleted' => true ] ; } } return FOSRestView :: create ( [ 'error' => sprintf ( 'Gallery "%s" does not have media "%s" associated' , $ galleryId , $ mediaId ) , ] , 400 ) ; }
Deletes a media association to a gallery.

@ApiDoc(
requirements={
{"name"="galleryId", "dataType"="integer", "requirement"="\d+", "description"="gallery identifier"},
{"name"="mediaId", "dataType"="integer", "requirement"="\d+", "description"="media identifier"}
},
statusCodes={
200="Returned when media is successfully deleted from gallery",
400="Returned when an error has occurred while media deletion of gallery",
404="Returned when unable to find gallery or media"
}
)

@param int $galleryId A gallery identifier
@param int $mediaId   A media identifier

@throws NotFoundHttpException

@return View
Deletes a media association to a gallery .