57 lines
1.5 KiB
PHP
57 lines
1.5 KiB
PHP
|
<?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)
|
||
|
{
|
||
|
}
|
||
|
|
||
|
#[Route('/', name: 'app_cpu_index', methods: ['GET'])]
|
||
|
public function index(): Response
|
||
|
{
|
||
|
return $this->itemListView('cpus', []);
|
||
|
}
|
||
|
|
||
|
#[Route('/new', name: 'app_cpu_new', methods: ['GET', 'POST'])]
|
||
|
public function new(Request $request): Response
|
||
|
{
|
||
|
return $this->itemCreate($request, 'cpu');
|
||
|
}
|
||
|
|
||
|
#[Route('/{id}', name: 'app_cpu_show', methods: ['GET'])]
|
||
|
public function show(Cpu $cpu): Response
|
||
|
{
|
||
|
return $this->itemView($cpu, 'cpu');
|
||
|
}
|
||
|
|
||
|
#[Route('/{id}/edit', name: 'app_cpu_edit', methods: ['GET', 'POST'])]
|
||
|
public function edit(Request $request, Cpu $cpu): Response
|
||
|
{
|
||
|
return $this->itemUpdate($request, $cpu, 'cpu');
|
||
|
}
|
||
|
|
||
|
#[Route('/{id}', name: 'app_cpu_delete', methods: ['POST'])]
|
||
|
public function delete(Request $request, Cpu $cpu): Response
|
||
|
{
|
||
|
return $this->deleteCSRF($request, $cpu);
|
||
|
}
|
||
|
}
|