SHARE
TWEET

CollabController.php

yamcsha Aug 25th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. class CollabController extends AbstractController
  4. {
  5.     /**
  6.      * @Route("/editmatform", name="collab_edit_mat_form", methods={"GET","POST"})
  7.      */
  8.     public function editmatform(Request $request)
  9.     {
  10.         $em = $this->getDoctrine()->getManager();
  11.         $id_collab = $request->request->get("collab");
  12.         $retiremat = $request->request->get("cbRetiremat");
  13.         $addMat = $request->request->get("cbAddmat");
  14.  
  15.         /** @var \App\Entity\Collab $collab */
  16.         $collab = $em->getRepository(Collab::class)->find($id_collab);
  17.         $materiels = $collab->getMateriels();
  18.  
  19.         if (! $retiremat) {
  20.             return $this->redirectToRoute('collab_edit_mat', ['id' => $id_collab]);
  21.         }
  22.  
  23.         foreach ($materiels as $materiel) {
  24.             if (in_array($materiel->getId(), $retiremat, false)) {
  25.                 $collab->removeMteriel($materiel);
  26.             }
  27.             $em->flush();
  28.         }
  29.  
  30.         return $this->redirectToRoute('collab_edit_mat', ['id' => $id_collab]);
  31.     }
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top