collection-crud/src/Controller/BrandCategoryController.php

55 lines
1.7 KiB
PHP
Raw Permalink Normal View History

2023-07-21 10:35:15 -04:00
<?php declare(strict_types=1);
2022-10-13 22:26:33 -04:00
namespace App\Controller;
use App\Entity\BrandCategory;
use App\Form\BrandCategoryType;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
2023-07-21 10:35:15 -04:00
use Symfony\Component\HttpFoundation\{Request, Response};
2022-10-13 22:26:33 -04:00
use Symfony\Component\Routing\Annotation\Route;
#[Route('/brand/category')]
2023-07-21 10:35:15 -04:00
class BrandCategoryController extends AbstractController {
2023-07-21 10:23:16 -04:00
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)
{
}
2023-07-21 10:35:15 -04:00
#[Route('/', name: 'brand-category_index', methods: ['GET'])]
public function index(): Response
{
return $this->indexView('brand_categories');
2023-07-21 10:35:15 -04:00
}
2022-10-13 22:26:33 -04:00
2023-07-21 10:35:15 -04:00
#[Route('/new', name: 'brand-category_new', methods: ['GET', 'POST'])]
public function new(Request $request, EntityManagerInterface $entityManager): Response
{
return $this->itemCreate($request, 'brand_category');
2023-07-21 10:35:15 -04:00
}
2022-10-13 22:26:33 -04:00
2023-07-21 10:35:15 -04:00
#[Route('/{name}', name: 'brand-category_show', methods: ['GET'])]
public function show(BrandCategory $brandCategory): Response
{
return $this->itemView($brandCategory, 'brand_category');
2023-07-21 10:35:15 -04:00
}
2022-10-13 22:26:33 -04:00
2023-07-21 10:35:15 -04:00
#[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');
2023-07-21 10:35:15 -04:00
}
2022-10-13 22:26:33 -04:00
2023-07-21 10:35:15 -04:00
#[Route('/{name}', name: 'brand-category_delete', methods: ['POST'])]
public function delete(Request $request, BrandCategory $brandCategory): Response
{
return $this->deleteCSRF($request, $brandCategory);
2023-07-21 10:35:15 -04:00
}
2022-10-13 22:26:33 -04:00
}