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