/** * @param UuidInterface $tagId * @param UuidInterface $imageId * @throws EntityNotFoundException */ public function removeImage(UuidInterface $tagId, UuidInterface $imageId) { $tag = $this->tagRepository->findOneById($tagId); $image = $this->imageRepository->findOneById($imageId); $tag->removeImage($image); $this->tagRepository->update($tag); if ($image->getProduct() === null) { $this->imageRepository->delete($image); } }
/** * @param UuidInterface $productId * @param UuidInterface $imageId * @throws EntityNotFoundException */ public function removeImage(UuidInterface $productId, UuidInterface $imageId) { $product = $this->productRepository->findOneById($productId); $image = $this->imageRepository->findOneById($imageId); $product->removeImage($image); $this->productRepository->update($product); if ($image->getTag() === null) { $this->imageRepository->delete($image); } }