public function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('loading countries...');
     $entityManager = $this->getContainer()->get('doctrine.orm.entity_manager');
     $repository = $entityManager->getRepository('BugglMainBundle:Country');
     $status = $this->getContainer()->get('buggl_main.constants')->get('APPROVED_COUNTRY');
     $countries = file_get_contents(__DIR__ . '/../../../../countries.json');
     $countries = json_decode($countries, true);
     $excluded = explode(':', $input->getArgument('excluded'));
     foreach ($countries as $country) {
         if (!(in_array($country, $excluded) || $repository->findByCountryName($country))) {
             $object = new Country();
             $object->setName($country);
             $object->setStatus($status);
             $entityManager->persist($object);
         }
     }
     $entityManager->flush();
     $output->writeln('done!');
 }
 private function verifyCountry($name)
 {
     $country = $this->getDoctrine()->getRepository('BugglMainBundle:Country')->findOneByName($name);
     if (!$country) {
         $country = new Country();
         $country->setName($name);
         $country->setStatus(1);
         $em = $this->getDoctrine()->getEntityManager();
         $em->persist($country);
         $em->flush();
     }
     return $country;
 }