2018-07-18 11:35:27 -04:00
|
|
|
<?php declare(strict_types=1);
|
2017-11-30 15:06:13 -05:00
|
|
|
|
2018-02-14 16:42:39 -05:00
|
|
|
namespace App\Controller;
|
2017-11-30 15:06:13 -05:00
|
|
|
|
2022-02-18 11:34:25 -05:00
|
|
|
use Doctrine\Persistence\ManagerRegistry;
|
2022-02-17 15:10:57 -05:00
|
|
|
use Symfony\Component\Form\FormInterface;
|
2018-02-14 16:42:39 -05:00
|
|
|
use App\Entity\Flash;
|
2018-07-16 13:10:00 -04:00
|
|
|
use App\Form\FlashType;
|
2018-11-30 16:01:30 -05:00
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
2022-02-18 11:34:25 -05:00
|
|
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
|
|
|
use Symfony\Component\HttpFoundation\Response;
|
2018-07-11 09:18:46 -04:00
|
|
|
use Symfony\Component\Routing\Annotation\Route;
|
2017-11-30 15:06:13 -05:00
|
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Flash controller.
|
|
|
|
*/
|
2022-02-17 15:16:47 -05:00
|
|
|
#[Route(path: 'flash')]
|
2018-11-30 16:01:30 -05:00
|
|
|
class FlashController extends AbstractController
|
2017-11-30 15:06:13 -05:00
|
|
|
{
|
2018-07-16 13:50:07 -04:00
|
|
|
use FormControllerTrait;
|
2022-02-18 11:34:25 -05:00
|
|
|
|
2018-07-16 13:50:07 -04:00
|
|
|
protected const ENTITY = Flash::class;
|
2022-02-18 11:34:25 -05:00
|
|
|
|
2018-07-16 13:50:07 -04:00
|
|
|
protected const FORM = FlashType::class;
|
2022-02-18 11:34:25 -05:00
|
|
|
|
|
|
|
public function __construct(private readonly ManagerRegistry $managerRegistry)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-11-30 15:06:13 -05:00
|
|
|
/**
|
|
|
|
* Lists all flash entities.
|
|
|
|
*/
|
2022-02-17 15:16:47 -05:00
|
|
|
#[Route(path: '/', name: 'flash_index', methods: ['GET'])]
|
2022-02-18 11:34:25 -05:00
|
|
|
public function indexAction(): Response
|
2017-11-30 15:06:13 -05:00
|
|
|
{
|
2018-07-16 13:50:07 -04:00
|
|
|
return $this->itemListView('flash/index.html.twig', 'flashes');
|
2017-11-30 15:06:13 -05:00
|
|
|
}
|
2022-02-18 11:34:25 -05:00
|
|
|
|
2017-11-30 15:06:13 -05:00
|
|
|
/**
|
|
|
|
* Creates a new flash entity.
|
|
|
|
*/
|
2022-02-17 15:16:47 -05:00
|
|
|
#[Route(path: '/new', name: 'flash_new', methods: ['GET', 'POST'])]
|
2022-02-18 11:34:25 -05:00
|
|
|
public function newAction(Request $request): RedirectResponse|Response
|
2017-11-30 15:06:13 -05:00
|
|
|
{
|
2018-07-16 13:50:07 -04:00
|
|
|
return $this->itemCreate($request, 'flash/new.html.twig', 'flash', 'flash_show');
|
2017-11-30 15:06:13 -05:00
|
|
|
}
|
2022-02-18 11:34:25 -05:00
|
|
|
|
2017-11-30 15:06:13 -05:00
|
|
|
/**
|
|
|
|
* Finds and displays a flash entity.
|
|
|
|
*/
|
2022-02-17 15:16:47 -05:00
|
|
|
#[Route(path: '/{id}', name: 'flash_show', methods: ['GET'])]
|
2022-02-18 11:34:25 -05:00
|
|
|
public function showAction(Flash $flash): Response
|
2017-11-30 15:06:13 -05:00
|
|
|
{
|
2018-07-16 13:50:07 -04:00
|
|
|
return $this->itemView($flash, 'flash/show.html.twig', 'flash');
|
2017-11-30 15:06:13 -05:00
|
|
|
}
|
2022-02-18 11:34:25 -05:00
|
|
|
|
2017-11-30 15:06:13 -05:00
|
|
|
/**
|
|
|
|
* Displays a form to edit an existing flash entity.
|
|
|
|
*/
|
2022-02-17 15:16:47 -05:00
|
|
|
#[Route(path: '/{id}/edit', name: 'flash_edit', methods: ['GET', 'POST'])]
|
2022-02-18 11:34:25 -05:00
|
|
|
public function editAction(Request $request, Flash $flash): RedirectResponse|Response
|
2017-11-30 15:06:13 -05:00
|
|
|
{
|
2018-07-16 13:50:07 -04:00
|
|
|
return $this->itemUpdate($request, $flash, 'flash/edit.html.twig', 'flash', 'flash_show');
|
2017-11-30 15:06:13 -05:00
|
|
|
}
|
2022-02-18 11:34:25 -05:00
|
|
|
|
2017-11-30 15:06:13 -05:00
|
|
|
/**
|
|
|
|
* Deletes a flash entity.
|
|
|
|
*/
|
2022-02-17 15:16:47 -05:00
|
|
|
#[Route(path: '/{id}', name: 'flash_delete', methods: ['DELETE'])]
|
2022-02-18 11:34:25 -05:00
|
|
|
public function deleteAction(Request $request, Flash $flash): RedirectResponse
|
2017-11-30 15:06:13 -05:00
|
|
|
{
|
2018-07-16 13:50:07 -04:00
|
|
|
return $this->itemDelete($request, $flash, 'flash_index');
|
2017-11-30 15:06:13 -05:00
|
|
|
}
|
2022-02-18 11:34:25 -05:00
|
|
|
|
2017-11-30 15:06:13 -05:00
|
|
|
/**
|
|
|
|
* Creates a form to delete a flash entity.
|
|
|
|
*/
|
2022-02-18 11:34:25 -05:00
|
|
|
private function createDeleteForm(Flash $flash): FormInterface
|
2017-11-30 15:06:13 -05:00
|
|
|
{
|
2018-07-16 13:50:07 -04:00
|
|
|
return $this->buildForm($flash, 'flash_delete', 'DELETE');
|
2017-11-30 15:06:13 -05:00
|
|
|
}
|
|
|
|
}
|