Пример #1
0
 public function createFromImport($ligne, $output)
 {
     $prenomNom = trim($ligne[self::CSV_IDENTITE]);
     $nom = substr(strrchr($prenomNom, " "), 1);
     $prenom = trim(str_replace($nom, '', $prenomNom));
     $societeAurouze = $this->dm->getRepository('AppBundle:Societe')->findOneByRaisonSociale("AUROUZE");
     if (!$societeAurouze) {
         $output->writeln(sprintf("<error>La société Aurouze n'a pas été trouvée</error>"));
         return false;
     }
     $compte = $this->dm->getRepository('AppBundle:Compte')->findOneByIdentifiantReprise($ligne[self::CSV_IDENTIFIANT]);
     if (isset($ligne[self::CSV_TYPE])) {
         if (!$compte) {
             $tag = new CompteTag();
             $tag->setIdentifiant($ligne[self::CSV_TYPE]);
             $tag->setNom(CompteManager::$tagsCompteLibelles[$ligne[self::CSV_TYPE]]);
             $this->dm->persist($tag);
             $compte = new Compte($societeAurouze);
             $compte->setIdentifiantReprise($ligne[self::CSV_IDENTIFIANT]);
             $compte->setNom($nom);
             $compte->setPrenom($prenom);
             $compte->setCouleur($this->random_color());
             $compte->addTag($tag);
             return $compte;
         } else {
             $tag = new CompteTag();
             $tag->setIdentifiant($ligne[self::CSV_TYPE]);
             $tag->setNom(CompteManager::$tagsCompteLibelles[$ligne[self::CSV_TYPE]]);
             $this->dm->persist($tag);
             $compte->addTag($tag);
             return $compte;
         }
     }
     return false;
 }
Пример #2
0
 public function reverseTransform($values)
 {
     $result = array();
     $tags = array();
     if ($this->compte) {
         $tags = $this->compte->getTagsArray();
     }
     $tagsPreCal = CompteManager::$tagsCompteLibelles;
     foreach ($values as $value) {
         if (!array_key_exists($value, $tags)) {
             $tag = new CompteTag();
             $tag->setNom($value);
             if (array_key_exists($value, $tagsPreCal)) {
                 $tag->setNom($tagsPreCal[$value]);
             }
             $this->compte->addTag($tag);
             $result[] = $tag;
         } else {
             $result[] = $tags[$value];
         }
     }
     return $result;
 }
Пример #3
0
 /**
  * Add tag
  *
  * @param AppBundle\Document\CompteTag $tag
  */
 public function addTag(\AppBundle\Document\CompteTag $tag)
 {
     foreach ($this->getTags() as $t) {
         if ($t->getIdentifiant() == $tag->getIdentifiant()) {
             return;
         }
     }
     $this->tags[] = $tag;
 }