src/Controller/Mantenimiento/SectorPlantaController.php line 31

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Mantenimiento;
  3. use App\Entity\Mantenimiento\SectorPlanta;
  4. use App\Form\Mantenimiento\SectorPlantaType;
  5. use App\Repository\Mantenimiento\SectorPlantaRepository;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. /**
  11.  * @Route("/mantenimiento/sector/planta")
  12.  */
  13. class SectorPlantaController extends AbstractController
  14. {
  15.     /**
  16.      * @Route("/", name="app_mantenimiento_sector_planta_index", methods={"GET"})
  17.      */
  18.     public function index(SectorPlantaRepository $sectorPlantaRepository): Response
  19.     {
  20.         return $this->render('mantenimiento/sector_planta/index.html.twig', [
  21.             'sector_plantas' => $sectorPlantaRepository->findAll(),
  22.         ]);
  23.     }
  24.     /**
  25.      * @Route("/new", name="app_mantenimiento_sector_planta_new", methods={"GET", "POST"})
  26.      */
  27.     public function new(Request $requestSectorPlantaRepository $sectorPlantaRepository): Response
  28.     {
  29.         $sectorPlantum = new SectorPlanta();
  30.         $form $this->createForm(SectorPlantaType::class, $sectorPlantum);
  31.         $form->handleRequest($request);
  32.         if ($form->isSubmitted() && $form->isValid()) 
  33.         {
  34.            /* $sectorPlantum->setFecha(new \DateTime())  
  35.                                    ->setUsuarioAlta($this->getUser());*/
  36.             $sectorPlantaRepository->add($sectorPlantumtrue);
  37.             return $this->redirectToRoute('app_mantenimiento_sector_planta_index', [], Response::HTTP_SEE_OTHER);
  38.         }
  39.         return $this->renderForm('mantenimiento/sector_planta/new.html.twig', [
  40.             'sector_plantum' => $sectorPlantum,
  41.             'form' => $form,
  42.         ]);
  43.     }
  44.     /**
  45.      * @Route("/{id}", name="app_mantenimiento_sector_planta_show", methods={"GET"})
  46.      */
  47.     public function show(SectorPlanta $sectorPlantum): Response
  48.     {
  49.         return $this->render('mantenimiento/sector_planta/show.html.twig', [
  50.             'sector_plantum' => $sectorPlantum,
  51.         ]);
  52.     }
  53.     /**
  54.      * @Route("/{id}/edit", name="app_mantenimiento_sector_planta_edit", methods={"GET", "POST"})
  55.      */
  56.     public function edit(Request $requestSectorPlanta $sectorPlantumSectorPlantaRepository $sectorPlantaRepository): Response
  57.     {
  58.         $form $this->createForm(SectorPlantaType::class, $sectorPlantum);
  59.         $form->handleRequest($request);
  60.         if ($form->isSubmitted() && $form->isValid()) {
  61.             $sectorPlantaRepository->add($sectorPlantumtrue);
  62.             return $this->redirectToRoute('app_mantenimiento_sector_planta_index', [], Response::HTTP_SEE_OTHER);
  63.         }
  64.         return $this->renderForm('mantenimiento/sector_planta/edit.html.twig', [
  65.             'sector_plantum' => $sectorPlantum,
  66.             'form' => $form,
  67.         ]);
  68.     }
  69.     /**
  70.      * @Route("/{id}", name="app_mantenimiento_sector_planta_delete", methods={"POST"})
  71.      */
  72.     public function delete(Request $requestSectorPlanta $sectorPlantumSectorPlantaRepository $sectorPlantaRepository): Response
  73.     {
  74.         if ($this->isCsrfTokenValid('delete'.$sectorPlantum->getId(), $request->request->get('_token'))) {
  75.             $sectorPlantaRepository->remove($sectorPlantumtrue);
  76.         }
  77.         return $this->redirectToRoute('app_mantenimiento_sector_planta_index', [], Response::HTTP_SEE_OTHER);
  78.     }
  79. }