Linux SRV-16 6.18.44-paas #1 SMP PREEMPT_DYNAMIC Thu Aug 13 10:08:12 UTC 2026 x86_64
/
srv
/
data
/
trash
/
vhost_www.bachtale.com_1719306535
/
htdocs
/
src
/
Controller
/
Back
/
/srv/data/trash/vhost_www.bachtale.com_1719306535/htdocs/src/Controller/Back/MetalController.php
<?php namespace App\Controller\Back; use App\Entity\Metal; use App\Form\MetalType; use App\Repository\MetalRepository; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; /** * @Route("/admin/metal") */ class MetalController extends AbstractController { /** * @Route("/", name="admin_metal_search", methods="GET") */ public function search(MetalRepository $metalRepository): Response { return $this->render('back/metal/search.html.twig', [ 'metals' => $metalRepository->findAll(), 'slug'=>'admin_metal', ]); } /** * @Route("/create", name="admin_metal_create", methods="GET|POST") */ public function create(Request $request): Response { $metal = new Metal(); $form = $this->createForm(MetalType::class, $metal); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($metal); $em->flush(); return $this->redirectToRoute('admin_metal_search'); } return $this->render('back/metal/create.html.twig', [ 'metal' => $metal, 'form' => $form->createView(), 'slug'=>'admin_metal', ]); } /** * @Route("/{id}", name="admin_metal_read", methods="GET") */ public function read(Metal $metal): Response { return $this->render('back/metal/read.html.twig', [ 'metal' => $metal, 'slug'=>'admin_metal', ]); } /** * @Route("/update/{id}", name="admin_metal_update", methods="GET|POST") */ public function update(Request $request, Metal $metal): Response { $form = $this->createForm(MetalType::class, $metal); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $this->getDoctrine()->getManager()->flush(); return $this->redirectToRoute('admin_metal_search'); } return $this->render('back/metal/update.html.twig', [ 'metal' => $metal, 'form' => $form->createView(), 'slug'=>'admin_metal', ]); } /** * @Route("/delete/{id}", name="admin_metal_delete", methods="DELETE") */ public function delete(Request $request, Metal $metal): Response { $msg = 'Enregistrement supprimé avec succès'; $em = $this->getDoctrine()->getManager(); $em->remove($metal); $em->flush(); $this->addFlash('success', $msg); return $this->redirectToRoute('admin_metal_search'); } }