collection-crud/src/Controller/SocketController.php

50 lines
1.4 KiB
PHP
Raw Normal View History

2023-07-21 10:35:15 -04:00
<?php declare(strict_types=1);
2022-10-20 11:07:27 -04:00
namespace App\Controller;
use App\Entity\Socket;
2023-07-21 10:23:16 -04:00
use App\Form\SocketTypeForm;
2022-10-20 11:07:27 -04:00
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
2023-07-21 10:35:15 -04:00
use Symfony\Component\HttpFoundation\{Request, Response};
2022-10-20 11:07:27 -04:00
use Symfony\Component\Routing\Annotation\Route;
#[Route('/socket')]
2023-07-21 10:35:15 -04:00
class SocketController extends AbstractController {
2023-07-21 10:23:16 -04:00
use FormControllerBase;
protected const ENTITY = Socket::class;
protected const ROUTE_PREFIX = 'socket_';
protected const TEMPLATE_PATH = 'socket/';
protected const FORM = SocketTypeForm::class;
2023-07-21 10:35:15 -04:00
#[Route('/', name: 'socket_index', methods: ['GET'])]
public function index(): Response
{
2023-07-21 10:23:16 -04:00
return $this->itemListView('sockets');
2023-07-21 10:35:15 -04:00
}
2022-10-20 11:07:27 -04:00
2023-07-21 10:35:15 -04:00
#[Route('/new', name: 'socket_new', methods: ['GET', 'POST'])]
public function new(Request $request): Response
{
2023-07-21 10:23:16 -04:00
return $this->itemCreate($request, 'sockets');
2023-07-21 10:35:15 -04:00
}
2022-10-20 11:07:27 -04:00
2023-07-21 10:35:15 -04:00
#[Route('/{id}', name: 'socket_show', methods: ['GET'])]
public function show(Socket $socket): Response
{
2023-07-21 10:23:16 -04:00
return $this->itemView($socket, 'socket');
2023-07-21 10:35:15 -04:00
}
2022-10-20 11:07:27 -04:00
2023-07-21 10:35:15 -04:00
#[Route('/{id}/edit', name: 'socket_edit', methods: ['GET', 'POST'])]
public function edit(Request $request, Socket $socket): Response
{
2023-07-21 10:23:16 -04:00
return $this->itemUpdate($request, $socket, 'socket');
2023-07-21 10:35:15 -04:00
}
2022-10-20 11:07:27 -04:00
2023-07-21 10:35:15 -04:00
#[Route('/{id}', name: 'socket_delete', methods: ['POST'])]
public function delete(Request $request, Socket $socket): Response
{
2023-07-21 10:23:16 -04:00
return $this->deleteCSRF($request, $socket);
2023-07-21 10:35:15 -04:00
}
2022-10-20 11:07:27 -04:00
}