Exemple #1
0
 protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
 {
     $em = $this->getHelper('em')->getEntityManager();
     $count = 0;
     if (($handle = fopen(DATADIR . "/people/people.txt", "r")) !== FALSE) {
         while (($data = fgetcsv($handle)) !== FALSE) {
             $type = substr($data[2], 5, 1);
             switch ($type) {
                 case 0:
                 case 1:
                     // This is a player
                     $player = new Player($data[2]);
                     $player->setName($data[1], $data[0]);
                     $em->persist($player);
                     //$output->writeln($player);
                     break;
                 case 8:
                     // Managers and coaches
                     $coach = new Coach($data[2]);
                     $coach->setName($data[1], $data[0]);
                     $em->persist($coach);
                     break;
                 case 9:
                     // Umpires
                     $umpire = new Umpire($data[2]);
                     $umpire->setName($data[1], $data[0]);
                     $em->persist($umpire);
                     break;
                 default:
                     throw new \Exception('Unknown type of person record');
             }
             if ($count % 500 == 0) {
                 $em->flush();
                 $em->clear();
                 $output->writeln("flusing {$count}");
             }
             $count++;
         }
     }
     fclose($handle);
     $em->flush();
 }
Exemple #2
0
 public function setName($firstName, $lastName)
 {
     $this->_load();
     return parent::setName($firstName, $lastName);
 }