private function createFakeProvider()
 {
     $provider = new Provider();
     $baseFaker = \Faker\Factory::create();
     $provider->setName($baseFaker->company);
     $provider->setCountry($baseFaker->country);
     $provider->setType($this->getRandomType());
     $provider->setDescription($baseFaker->text(500));
     $provider->setUrl($baseFaker->url);
     $provider->setLastModification($baseFaker->dateTime);
     $nb = rand(1, 5);
     for ($x = 0; $x <= $nb; $x++) {
         $contactFaker = \Faker\Factory::create();
         $c = new Contact();
         $c->setProvider($provider);
         $c->setFirstName($contactFaker->firstName);
         $c->setLastName($contactFaker->lastName);
         $c->setGender(Personne::GENDER_MALE);
         $c->setEmail($contactFaker->email);
         $c->setTelephone($contactFaker->phoneNumber);
         $c->setDescription($contactFaker->text(300));
         $c->setComment($contactFaker->text(100));
         $this->output('create fake contact');
         $this->em->persist($c);
     }
     $this->em->persist($provider);
     $this->output('create fake provider');
     return $provider;
 }
Exemple #2
0
 private function createProvider($name, $type, $url, $country, $description, $log)
 {
     try {
         $p = new Provider();
         //if(($name == '') || ($name == null))
         //throw new \Exception();
         $p->setName($name);
         /*
         $this->output('$name: '.$name);
                     $this->output('$type: '.$type);
                     $this->output('$url: '.$url);
                     $this->output('$country: '.$country);
         */
         $p->setType($this->to_provider_type($type));
         $p->setUrl($url);
         $p->setCountry($this->country_to_code($country));
         $p->setDescription($description);
         $p->setComment($log);
         $this->em->persist($p);
         $this->em->flush();
         return $p;
     } catch (\Exception $e) {
         echo $e->getMessage();
         $this->output('cannot creat provider', 'error');
         return null;
     }
 }