예제 #1
0
 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;
 }
예제 #2
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $providerData = [['Partzilla', 'http://partzilla.com', 'USD', 9, null], ['Ronayers', 'http://ronayers.com', 'USD', 12, 19], ['Megazip', 'http://megazip.ru', 'RUB', 24, null]];
     foreach ($providerData as $providerDataItem) {
         list($providerName, $providerUrl, $providerCurrency, $providerDeliveryLeft, $providerDeliveryRight, ) = $providerDataItem;
         $provider = new Provider();
         $provider->setName($providerName);
         $provider->setUrl($providerUrl);
         $provider->setCurrency($providerCurrency);
         $provider->setDeliveryLeft($providerDeliveryLeft);
         $provider->setDeliveryRight($providerDeliveryRight);
         $manager->persist($provider);
         $this->addReference('provider-' . strtolower($providerName), $provider);
     }
     $manager->flush();
 }
예제 #3
0
 public function load(ObjectManager $manager)
 {
     $provider = new Provider();
     $provider->setName('Fastweb');
     $provider->setActive(true);
     $provider->setApi('fw');
     $provider->setDescription('');
     $provider->setShortDescription('');
     $provider->setIdProvider(1);
     $provider->setOffersLink('');
     $manager->persist($provider);
     $manager->flush();
     $provider = new Provider();
     $provider->setName('Tim');
     $provider->setActive(true);
     $provider->setApi('tlcm');
     $provider->setDescription('');
     $provider->setShortDescription('');
     $provider->setIdProvider(2);
     $provider->setOffersLink('');
     $manager->persist($provider);
     $manager->flush();
     $provider = new Provider();
     $provider->setName('Vodafone');
     $provider->setActive(true);
     $provider->setApi('vdfn');
     $provider->setDescription('');
     $provider->setShortDescription('');
     $provider->setIdProvider(4);
     $provider->setOffersLink('');
     $manager->persist($provider);
     $manager->flush();
     $provider = new Provider();
     $provider->setName('Tiscali');
     $provider->setActive(true);
     $provider->setApi('tiscali');
     $provider->setDescription('');
     $provider->setShortDescription('');
     $provider->setIdProvider(5);
     $provider->setOffersLink('');
     $manager->persist($provider);
     $manager->flush();
     $provider = new Provider();
     $provider->setName('Infostrada');
     $provider->setActive(true);
     $provider->setApi('infostrada');
     $provider->setDescription('');
     $provider->setShortDescription('');
     $provider->setIdProvider(6);
     $provider->setOffersLink('');
     $manager->persist($provider);
     $manager->flush();
     $provider = new Provider();
     $provider->setName('Eolo');
     $provider->setActive(true);
     $provider->setApi('eolo');
     $provider->setDescription('');
     $provider->setShortDescription('');
     $provider->setIdProvider(7);
     $provider->setOffersLink('');
     $manager->persist($provider);
     $manager->flush();
     $provider = new Provider();
     $provider->setName('Linkem');
     $provider->setActive(true);
     $provider->setApi('fw');
     $provider->setDescription('');
     $provider->setShortDescription('');
     $provider->setIdProvider(9);
     $provider->setOffersLink('');
     $manager->persist($provider);
     $manager->flush();
 }
예제 #4
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;
     }
 }