2022-09-30 10:49:02 -04:00
|
|
|
<?php declare(strict_types=1);
|
2022-09-29 20:09:31 -04:00
|
|
|
|
|
|
|
namespace App\Controller;
|
|
|
|
|
|
|
|
use App\Entity\Brand;
|
|
|
|
use App\Form\BrandType;
|
2022-09-30 10:48:14 -04:00
|
|
|
use App\Traits\FormControllerTrait;
|
2022-09-29 20:09:31 -04:00
|
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
2022-09-30 10:49:02 -04:00
|
|
|
use Symfony\Component\HttpFoundation\{Request, Response};
|
2022-09-29 20:09:31 -04:00
|
|
|
use Symfony\Component\Routing\Annotation\Route;
|
|
|
|
|
|
|
|
#[Route('/brand')]
|
|
|
|
class BrandController extends AbstractController
|
|
|
|
{
|
2022-09-30 10:49:02 -04:00
|
|
|
use FormControllerTrait;
|
2022-09-29 20:09:31 -04:00
|
|
|
|
2022-09-30 10:49:02 -04:00
|
|
|
protected const ENTITY = Brand::class;
|
|
|
|
protected const TEMPLATE_PATH = 'brand/';
|
|
|
|
protected const ROUTE_PREFIX = 'brand_';
|
|
|
|
protected const FORM = BrandType::class;
|
2022-09-29 20:09:31 -04:00
|
|
|
|
2022-09-30 10:49:02 -04:00
|
|
|
public function __construct(private readonly EntityManagerInterface $entityManager)
|
|
|
|
{
|
|
|
|
}
|
2022-09-29 20:09:31 -04:00
|
|
|
|
|
|
|
#[Route('/', name: 'brand_index', methods: ['GET'])]
|
2022-09-30 10:48:14 -04:00
|
|
|
public function index(): Response
|
2022-09-29 20:09:31 -04:00
|
|
|
{
|
2022-09-30 10:49:02 -04:00
|
|
|
return $this->itemListView('brands', [
|
|
|
|
'name' => 'asc',
|
|
|
|
]);
|
2022-09-29 20:09:31 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#[Route('/new', name: 'brand_new', methods: ['GET', 'POST'])]
|
2022-09-30 10:48:14 -04:00
|
|
|
public function new(Request $request): Response
|
2022-09-29 20:09:31 -04:00
|
|
|
{
|
2022-09-30 10:49:02 -04:00
|
|
|
return $this->itemCreate($request, 'brand');
|
2022-09-29 20:09:31 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#[Route('/{id}', name: 'brand_show', methods: ['GET'])]
|
|
|
|
public function show(Brand $brand): Response
|
|
|
|
{
|
2022-09-30 10:49:02 -04:00
|
|
|
return $this->itemView($brand, 'brand');
|
2022-09-29 20:09:31 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#[Route('/{id}/edit', name: 'brand_edit', methods: ['GET', 'POST'])]
|
2022-09-30 10:48:14 -04:00
|
|
|
public function edit(Request $request, Brand $brand): Response
|
2022-09-29 20:09:31 -04:00
|
|
|
{
|
2022-09-30 10:49:02 -04:00
|
|
|
return $this->itemUpdate($request, $brand, 'brand');
|
2022-09-29 20:09:31 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#[Route('/{id}', name: 'brand_delete', methods: ['POST'])]
|
2022-09-30 10:48:14 -04:00
|
|
|
public function delete(Request $request, Brand $brand): Response
|
2022-09-29 20:09:31 -04:00
|
|
|
{
|
2022-09-30 10:49:02 -04:00
|
|
|
return $this->deleteCSRF($request, $brand);
|
2022-09-29 20:09:31 -04:00
|
|
|
}
|
|
|
|
}
|