Пример #1
0
 public function createInstitutionIfNotExists(Institution $institution)
 {
     $em = $this->scraper->getManager();
     $ins = $em->getRepository('ClassCentralSiteBundle:Institution')->findOneBy(array('slug' => $institution->getSlug()));
     if ($ins) {
         // Institution exists
         return $ins;
     }
     if ($this->scraper->doCreate()) {
         $this->scraper->out("NEW INSTITUTION:  {$institution->getName()}");
         if ($this->scraper->doModify()) {
             $em->persist($institution);
             $em->flush();
         }
     }
     return $institution;
 }