Ejemplo n.º 1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $em = $this->getContainer()->get('doctrine')->getManager();
     $list = $input->getArgument('unilist');
     $lines = file($list, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
     if ($lines == false) {
         $text = 'There was an error reading the university list.';
     } else {
         foreach ($lines as $line) {
             $u = explode("|", $line);
             $uni = new University();
             $uni->setName($u[0]);
             $uni->setCountry($u[1]);
             $em->persist($uni);
         }
         $em->flush();
         $text = 'Loaded university names.';
     }
     $output->writeln($text);
 }
Ejemplo n.º 2
0
 /**
  * Set university
  *
  * @param \AB\Bundle\Entity\University $university
  * @return Course
  */
 public function setUniversity(\AB\Bundle\Entity\University $university = null)
 {
     $university->addCourse($this);
     $this->university = $university;
     return $this;
 }