private static function getFromInstitution(Institution $entity) { $info = new PageHeaderInfo("Institution"); $info->setName($entity->getName() . ' | Free Online Courses'); $info->setUrl($entity->getUrl()); $info->setDescription($entity->getDescription()); if ($entity->getImageUrl()) { $info->setImageUrl($entity->getImageDir() . '/' . $entity->getImageUrl()); } return $info; }
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; }