public function saveAction() { $request = Request::createFromGlobals(); $id = $request->get('id'); $session = $this->container->get('arii_core.session'); $enterprise_id = $session->getEnterpriseId(); $enterprise = $this->getDoctrine()->getRepository("AriiCoreBundle:Enterprise")->find($enterprise_id); $em = $this->getDoctrine()->getManager(); if ($id != "") { $spooler = $this->getDoctrine()->getRepository("AriiCoreBundle:Spooler")->find($id); $connection = $spooler->getConnection(); $connection->setTitle($request->get('scheduler')); $connection->setDescription($request->get('spooler_description')); $connection->setHost($request->get('host')); $connection->setInterface($request->get('ip')); $connection->setPort($request->get('port')); $em->persist($connection); $em->flush(); $spooler->setConnection($connection); } else { $spooler = new \Arii\CoreBundle\Entity\Spooler(); $connection = new \Arii\CoreBundle\Entity\Connection(); $connection->setEnterprise($enterprise); $connection->setTitle($request->get('scheduler')); $connection->setDescription($request->get('spooler_description')); $connection->setHost($request->get('host')); $connection->setInterface($request->get('ip')); $connection->setPort($request->get('port')); $network_spooler = $this->getDoctrine()->getRepository("AriiCoreBundle:Network")->findOneBy(array('protocol' => 'osjs')); $connection->setNetwork($network_spooler); $em->persist($connection); $em->flush(); $spooler->setConnection($connection); $spooler->setClusterOptions('-exclusive'); $spooler->setOsTarget(\php_uname('s')); $spooler->setLicence(''); $spooler->setInstallDate(new \DateTime()); $spooler->setStatusDate(new \DateTime()); } if ($request->get('name') == "") { $spooler->setName($request->get('scheduler')); } else { $spooler->setName($request->get('name')); } $spooler->setDescription($request->get('spooler_description')); $spooler->setScheduler($request->get('scheduler')); if ($request->get('supervisor_id') != "") { $supervisor = $this->getDoctrine()->getRepository("AriiCoreBundle:Spooler")->find($request->get('supervisor_id')); $spooler->setSupervisor($supervisor); } if ($request->get('primary_id') != "") { $backup = $this->getDoctrine()->getRepository("AriiCoreBundle:Spooler")->find($request->get('primary_id')); $spooler->setPrimary($backup); } if ($request->get('site_id') != "") { $site = $this->getDoctrine()->getRepository("AriiCoreBundle:Site")->find($request->get('site_id')); $spooler->setSite($site); } if ($request->get('smtp_id') != "") { $smtp = $this->getDoctrine()->getRepository("AriiCoreBundle:Connection")->find($request->get('smtp_id')); $spooler->setSmtp($smtp); } if ($request->get('db_id') != "") { $db = $this->getDoctrine()->getRepository("AriiCoreBundle:Connection")->find($request->get('db_id')); $spooler->setDb($db); } $spooler->setTimezone($request->get('timezone')); $spooler->setInstallPath($request->get('install_path')); $spooler->setUserPath($request->get('user_path')); $spooler->setVersion($this->container->getParameter('osjs_version')); $spooler->setEvents($request->get('events')); $spooler->setRemote($request->get('remote')); $em->persist($spooler); $em->flush(); return new Response("success"); }