2022-10-27 11:55:16 -04:00
|
|
|
<?php declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace App\Controller;
|
|
|
|
|
|
|
|
use App\Entity\Cpu;
|
|
|
|
use App\Form\CpuType;
|
|
|
|
use App\Traits\FormControllerTrait;
|
|
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
use Symfony\Component\Routing\Annotation\Route;
|
|
|
|
|
|
|
|
#[Route('/cpu')]
|
|
|
|
class CpuController extends AbstractController {
|
|
|
|
use FormControllerTrait;
|
|
|
|
|
|
|
|
protected const ENTITY = Cpu::class;
|
|
|
|
protected const TEMPLATE_PATH = 'cpu/';
|
|
|
|
protected const ROUTE_PREFIX = 'cpu_';
|
|
|
|
protected const FORM = CpuType::class;
|
|
|
|
|
|
|
|
public function __construct(private readonly EntityManagerInterface $entityManager)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-10-28 08:46:35 -04:00
|
|
|
#[Route('/', name: 'cpu_index', methods: ['GET'])]
|
2022-10-27 11:55:16 -04:00
|
|
|
public function index(): Response
|
|
|
|
{
|
|
|
|
return $this->itemListView('cpus', []);
|
|
|
|
}
|
|
|
|
|
2022-10-28 08:46:35 -04:00
|
|
|
#[Route('/new', name: 'cpu_new', methods: ['GET', 'POST'])]
|
2022-10-27 11:55:16 -04:00
|
|
|
public function new(Request $request): Response
|
|
|
|
{
|
|
|
|
return $this->itemCreate($request, 'cpu');
|
|
|
|
}
|
|
|
|
|
2022-10-28 08:46:35 -04:00
|
|
|
#[Route('/{id}', name: 'cpu_show', methods: ['GET'])]
|
2022-10-27 11:55:16 -04:00
|
|
|
public function show(Cpu $cpu): Response
|
|
|
|
{
|
|
|
|
return $this->itemView($cpu, 'cpu');
|
|
|
|
}
|
|
|
|
|
2022-10-28 08:46:35 -04:00
|
|
|
#[Route('/{id}/edit', name: 'cpu_edit', methods: ['GET', 'POST'])]
|
2022-10-27 11:55:16 -04:00
|
|
|
public function edit(Request $request, Cpu $cpu): Response
|
|
|
|
{
|
|
|
|
return $this->itemUpdate($request, $cpu, 'cpu');
|
|
|
|
}
|
|
|
|
|
2022-10-28 08:46:35 -04:00
|
|
|
#[Route('/{id}', name: 'cpu_delete', methods: ['POST'])]
|
2022-10-27 11:55:16 -04:00
|
|
|
public function delete(Request $request, Cpu $cpu): Response
|
|
|
|
{
|
|
|
|
return $this->deleteCSRF($request, $cpu);
|
|
|
|
}
|
|
|
|
}
|