collection-crud/src/Controller/SocketController.php

52 lines
1.5 KiB
PHP
Raw Normal View History

2022-10-20 11:07:27 -04:00
<?php
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;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
#[Route('/socket')]
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;
2022-10-20 11:07:27 -04:00
#[Route('/', name: 'socket_index', methods: ['GET'])]
2023-07-21 10:23:16 -04:00
public function index(): Response
2022-10-20 11:07:27 -04:00
{
2023-07-21 10:23:16 -04:00
return $this->itemListView('sockets');
2022-10-20 11:07:27 -04:00
}
#[Route('/new', name: 'socket_new', methods: ['GET', 'POST'])]
2023-07-21 10:23:16 -04:00
public function new(Request $request): Response
2022-10-20 11:07:27 -04:00
{
2023-07-21 10:23:16 -04:00
return $this->itemCreate($request, 'sockets');
2022-10-20 11:07:27 -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');
2022-10-20 11:07:27 -04:00
}
#[Route('/{id}/edit', name: 'socket_edit', methods: ['GET', 'POST'])]
2023-07-21 10:23:16 -04:00
public function edit(Request $request, Socket $socket): Response
2022-10-20 11:07:27 -04:00
{
2023-07-21 10:23:16 -04:00
return $this->itemUpdate($request, $socket, 'socket');
2022-10-20 11:07:27 -04:00
}
#[Route('/{id}', name: 'socket_delete', methods: ['POST'])]
2023-07-21 10:23:16 -04:00
public function delete(Request $request, Socket $socket): Response
2022-10-20 11:07:27 -04:00
{
2023-07-21 10:23:16 -04:00
return $this->deleteCSRF($request, $socket);
2022-10-20 11:07:27 -04:00
}
}