Example #1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $em = $this->getContainer()->get('doctrine.orm.entity_manager');
     $file = $input->getArgument('file');
     $teams = json_decode(file_get_contents($file));
     foreach ($teams as $team) {
         $t = new Team();
         $t->setName($team->name);
         $t->setWsId($team->id);
         $em->persist($t);
     }
     $em->flush();
     $io->success('Added ' . count($teams) . ' teams.');
 }
 public function getRegionTeams(Region $region)
 {
     $teams = $this->whoscored->loadStatistics('regionteams', array('id' => $region->getWsId()));
     foreach ($teams as $team) {
         if ($this->em->getRepository('AppBundle:Team')->findOneByWsId($team[0]) !== null) {
             continue;
         }
         $ret = new Team();
         $ret->setWsId($team[0]);
         $ret->setName($team[1]);
         $this->em->persist($ret);
         unset($ret);
     }
     $this->em->flush();
 }