/** * @Route("/compte/{id}/etat", name="compte_update_etat") * @ParamConverter("compte", class="AppBundle:Compte") */ public function updateEtatAction(Request $request, Compte $compte) { if (!$request->isXmlHttpRequest()) { throw $this->createNotFoundException(); } $dm = $this->get('doctrine_mongodb')->getManager(); if ($compte) { try { $compte->setActif($request->get('etat')); $dm->persist($compte); $dm->flush(); return new Response(json_encode(array("success" => true))); } catch (\Exception $e) { } } throw new \Exception('Une erreur s\'est produite'); }
public function createContactFromImport($ligne, $output) { $identifiantRepriseEtablissement = $ligne[self::CSV_IDENTIFIANT_REPRISE_ETABLISSEMENT]; $identifiantRepriseSociete = $ligne[self::CSV_IDENTIFIANT_REPRISE_SOCIETE]; $etablissement = $this->dm->getRepository('AppBundle:Etablissement')->findOneByIdentifiantReprise($identifiantRepriseEtablissement); $societe = null; if ($etablissement) { $societe = $etablissement->getSociete(); } if (!$societe) { $societe = $this->dm->getRepository('AppBundle:Societe')->findOneByIdentifiantReprise($identifiantRepriseSociete); } if (!$societe) { $output->writeln(sprintf("\n<error>La société d'identifiant de reprise %s n'a pas été trouvée (etb? = %s)</error>", $identifiantRepriseSociete, $identifiantRepriseEtablissement)); return false; } $compte = new Compte($societe); $compte->setSociete($societe); $compte->setIdentifiantReprise($ligne[self::CSV_IDENTIFIANT_REPRISE_CONTACT]); $compte->setCivilite($this->getCivilite($ligne[self::CSV_CIVILITE])); $compte->setPrenom($ligne[self::CSV_PRENOM]); $compte->setNom($ligne[self::CSV_NOM]); $compte->setIdentite($compte->getIdentite()); $compte->setTitre($this->getTitre($ligne[self::CSV_TITRE])); $contactCoordonnee = new ContactCoordonnee(); $contactCoordonnee->setTelephoneFixe($ligne[self::CSV_TELEPHONE_FIXE]); $contactCoordonnee->setTelephoneMobile($ligne[self::CSV_TELEPHONE_PORTABLE]); $contactCoordonnee->setFax($ligne[self::CSV_FAX]); $contactCoordonnee->setEmail($ligne[self::CSV_EMAIL]); $compte->setContactCoordonnee($contactCoordonnee); $compte->setActif(boolval($ligne[self::CSV_ACTIF])); $adresse = new Adresse(); $compte->setAdresse($adresse); $this->dm->persist($compte); return $compte; }