public function saveAction() { // On recupere les informations de dhtmlx $request = Request::createFromGlobals(); // On récupère le repository $repository = $this->getDoctrine()->getManager()->getRepository('AriiJOEBundle:Job'); // print_r($_POST); // On récupère l'entité correspondant à l'id $id $job = $repository->find($request->get('id')); if ($job === null) { // Création de l'entité $job = new Job(); print "New JOB !<hr/>"; } // On récupére l'EntityManager $em = $this->getDoctrine()->getManager(); $job->setName($request->get('name')); $job->setTitle($request->get('title')); $job->setCategory($request->get('category')); $job->setActivated(true); $job->setJobType($request->get('job_type')); $job->setMinTasks($request->get('min_tasks')); $job->setProcessClass($request->get('process_class')); $job->setWarnIfLongerThan($request->get('warn_if_longer_than')); $job->setWarnIfShorterThan($request->get('warn_if_shorter_than')); if ($request->get('tasks') > 0) { $job->setTasks($request->get('tasks')); } $job->setStartWhenDirectoryChanged($request->get('file_time') == 'file_watcher'); $job->setDirectory($request->get('directory')); $job->setRegex($request->get('regex')); $job->setSendEvent($request->get('sendevent')); $job->setEventClass($request->get('event_class')); $job->setEventId($request->get('event_id')); $job->setSpoolerId(''); $em->persist($job); // on attache le script /* $script = new Script(); $script->setLanguage('shell'); $script->setCode( $request->get('code') ); $job->setScript($script); $em->persist($script); */ /* // on supprime les anciens parametres $Params = $job->GetParamsJob(); foreach ($Params as $p) { $em->remove($p); } // On recupere les parametres de la grille $n=0; for($i=1;$i<30;$i++) { if ($request->get('var'.$i)!='') { $param{$n} = new ParamJob(); $param{$n}->setName($request->get('var'.$i)); $param{$n}->setValue($request->get('val'.$i)); $param{$n}->setJob($job); $em->persist($param{$n}); $n++; } } */ $em->flush(); // print $job->getCategory().'/'.$job->getName(); print $job->getId(); exit; }