collection-crud/src/Controller/FlashController.php

76 lines
1.9 KiB
PHP
Raw Normal View History

2018-07-18 11:35:27 -04:00
<?php declare(strict_types=1);
2017-11-30 15:06:13 -05:00
namespace App\Controller;
2017-11-30 15:06:13 -05:00
2023-07-21 10:23:16 -04:00
use App\Controller\
{DeleteFormTrait};
2023-07-21 10:35:15 -04:00
use App\Entity\Flash;
use App\Form\FlashType;
2022-09-29 18:35:53 -04:00
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
2022-03-03 11:15:12 -05:00
use Symfony\Component\HttpFoundation\{RedirectResponse, Request, 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.
*/
#[Route(path: 'flash')]
2023-07-21 10:35:15 -04:00
class FlashController extends AbstractController {
use FormControllerBase;
use DeleteFormTrait;
2022-02-18 11:34:25 -05:00
2023-07-21 10:35:15 -04:00
protected const ENTITY = Flash::class;
protected const TEMPLATE_PATH = 'flash/';
protected const ROUTE_PREFIX = 'flash_';
protected const FORM = FlashType::class;
2022-02-18 11:34:25 -05:00
2023-07-21 10:35:15 -04:00
public function __construct(private readonly EntityManagerInterface $entityManager)
{
}
2022-02-18 11:34:25 -05:00
2023-07-21 10:35:15 -04:00
/**
* Lists all flash entities.
*/
#[Route(path: '/', name: 'flash_index', methods: ['GET'])]
public function indexAction(): Response
{
return $this->itemListView('flashes');
}
2022-02-18 11:34:25 -05:00
2023-07-21 10:35:15 -04: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');
}
2022-02-18 11:34:25 -05:00
2023-07-21 10:35:15 -04: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');
}
2022-02-18 11:34:25 -05:00
2023-07-21 10:35:15 -04: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');
}
2022-02-18 11:34:25 -05:00
2023-07-21 10:35:15 -04:00
/**
* Deletes a flash entity.
*/
#[Route(path: '/{id}', name: 'flash_delete', methods: ['POST', 'DELETE'])]
public function deleteAction(Request $request, Flash $flash): RedirectResponse
{
return $this->itemDelete($request, $flash);
}
2017-11-30 15:06:13 -05:00
}