<?php

/*
 * This file is part of the Serenity package.
 *
 * (c) CP Creation <web@cpcreation.fr>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace CpCreation\VitiCore\Bridge\Symfony\Bundle\Controller\Admin;

use CpCreation\VitiCore\Media\Model\Media;
use CpCreation\VitiCore\Media\Repository\MediaRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Attribute\Route;

#[Route('/medias')]
final class MediaController extends AbstractController
{
    public function __construct(
        private readonly MediaRepository $mediaRepository,
    ) {
    }

    #[Route(
        '/{id}/delete',
        name: 'media_delete',
        options: ['expose' => true]
    )]
    public function delete(Media $media): JsonResponse
    {
        $this->mediaRepository->delete($media);

        return $this->json([
            'message' => '',
        ], 200);
    }
}
