示例#1
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;
     }
 }