collection-crud/src/Controller/BrandCategoryController.php

55 lines
1.7 KiB
PHP

<?php declare(strict_types=1);
namespace App\Controller;
use App\Entity\BrandCategory;
use App\Form\BrandCategoryType;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\{Request, Response};
use Symfony\Component\Routing\Annotation\Route;
#[Route('/brand/category')]
class BrandCategoryController extends AbstractController {
use FormControllerBase;
protected const ENTITY = BrandCategory::class;
protected const TEMPLATE_PATH = 'brand_category/';
protected const ROUTE_PREFIX = 'brand-category_';
protected const FORM = BrandCategoryType::class;
public function __construct(private readonly EntityManagerInterface $entityManager)
{
}
#[Route('/', name: 'brand-category_index', methods: ['GET'])]
public function index(): Response
{
return $this->indexView('brand_categories');
}
#[Route('/new', name: 'brand-category_new', methods: ['GET', 'POST'])]
public function new(Request $request, EntityManagerInterface $entityManager): Response
{
return $this->itemCreate($request, 'brand_category');
}
#[Route('/{name}', name: 'brand-category_show', methods: ['GET'])]
public function show(BrandCategory $brandCategory): Response
{
return $this->itemView($brandCategory, 'brand_category');
}
#[Route('/{name}/edit', name: 'brand-category_edit', methods: ['GET', 'POST'])]
public function edit(Request $request, BrandCategory $brandCategory): Response
{
return $this->itemUpdate($request, $brandCategory, 'brand_category');
}
#[Route('/{name}', name: 'brand-category_delete', methods: ['POST'])]
public function delete(Request $request, BrandCategory $brandCategory): Response
{
return $this->deleteCSRF($request, $brandCategory);
}
}