public function run()
 {
     global $request;
     $em = \Shared\DoctrineHelper::getEntityManager();
     $idAdmins = $request->request->get("idAdmins");
     $idCompte = $request->request->get("idCompte");
     $adminName = $request->request->get("adminName");
     $arrDroitsParam = json_decode($request->request->get("arrDroits"));
     $arrDroitsNew = [];
     if ($idAdmins > 0) {
         $objAdmins = \Site\SiteHelper::getAdminsRepository()->find($idAdmins);
         $arrDroitsOld = $objAdmins->getDroits();
     } else {
         $objAdmins = new \Site\Entity\Admins();
         $objAdmins->setEstActif(1);
         $arrDroitsOld = [];
     }
     $objAdmins->setIdCompte($idCompte);
     $objAdmins->setName($adminName);
     foreach ($arrDroitsParam as $idDroit => $droitParam) {
         if ($droitParam) {
             $arrDroitsNew[] = $idDroit;
         } else {
             if (($key = array_search($idDroit, $arrDroitsOld)) !== false) {
                 unset($arrDroitsOld[$key]);
             }
         }
     }
     $objAdmins->setDroits($arrDroitsNew + $arrDroitsOld);
     $em->persist($objAdmins);
     $em->flush();
 }
 public function run()
 {
     global $request;
     $mode = $request->query->get("mode");
     $objAccount = null;
     if ($mode == "create") {
         $objAdmins = new \Site\Entity\Admins();
         $arrDroits = $objAdmins->getDroits();
     } else {
         if ($mode == "mod") {
             $id = $request->query->get("idAdmins");
             $objAdmins = \Site\SiteHelper::getAdminsRepository()->find($id);
             $arrDroits = $objAdmins->getDroits();
             $objAccount = \Account\AccountHelper::getAccountRepository()->find($objAdmins->getIdCompte());
         }
     }
     $this->arrayTemplate["objAdmins"] = $objAdmins;
     $this->arrayTemplate["arrDroits"] = $arrDroits;
     $this->arrayTemplate["objAccount"] = $objAccount;
     $view = $this->template->render($this->arrayTemplate);
     $this->response->setContent($view);
     $this->response->send();
 }