protected function execute(InputInterface $input, OutputInterface $output)
 {
     $emName = $input->getOption('em');
     $emName = $emName ? $emName : 'default';
     $emServiceName = sprintf('doctrine.orm.%s_entity_manager', $emName);
     $em = $this->container->get($emServiceName);
     $dirOrFile = $input->getOption('fixtures');
     if ($dirOrFile) {
         $paths = is_array($dirOrFile) ? $dirOrFile : array($dirOrFile);
     } else {
         $paths = array();
         foreach ($this->application->getKernel()->getBundles() as $bundle) {
             $paths[] = $bundle->getPath() . '/DataFixtures/ORM';
         }
     }
     $loader = new DataFixturesLoader($this->container);
     foreach ($paths as $path) {
         if (is_dir($path)) {
             $loader->loadFromDirectory($path);
         }
     }
     $fixtures = $loader->getFixtures();
     $purger = new ORMPurger($em);
     $executor = new ORMExecutor($em, $purger);
     $executor->setLogger(function ($message) use($output) {
         $output->writeln(sprintf('  <comment>></comment> <info>%s</info>', $message));
     });
     $executor->execute($fixtures, $input->getOption('append'));
 }
Exemple #2
0
 /**
  * Executes the current command.
  *
  * This method is not abstract because you can use this class
  * as a concrete class. In this case, instead of defining the
  * execute() method, you set the code to execute by passing
  * a Closure to the setCode() method.
  *
  * @param InputInterface $input An InputInterface instance
  * @param OutputInterface $output An OutputInterface instance
  *
  * @return null|int null or 0 if everything went fine, or an error code
  *
  * @throws LogicException When this abstract method is not implemented
  *
  * @see setCode()
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var QuestionHelper $helper */
     $helper = $this->getHelper('question');
     $question = new ConfirmationQuestion('All data in User table will be purged before inserting default data.
          Are you sure you want to continue?', false);
     if (!$helper->ask($input, $output, $question)) {
         return;
     }
     try {
         $loader = new Loader();
         $loader->loadFromDirectory(__DIR__ . '/../fixtures');
         $fixtures = $loader->getFixtures();
         $purger = new ORMPurger($this->em);
         $executor = new ORMExecutor($this->em, $purger);
         $executor->setLogger(function ($message) use($output) {
             $output->writeln(sprintf('  <comment>></comment> <info>%s</info>', $message));
         });
         $executor->execute($fixtures);
         $output->writeln('Default users have been successfully loaded!');
         return 0;
     } catch (\Exception $e) {
         $output->writeLn("That's bad. An Error occurred: <error>{$e->getMessage()}</error>");
         return 1;
     }
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $emName = $input->getOption('em');
     $emName = $emName ? $emName : 'default';
     $emServiceName = sprintf('doctrine.orm.%s_entity_manager', $emName);
     if (!$this->getContainer()->has($emServiceName)) {
         throw new InvalidArgumentException(sprintf('Could not find an entity manager configured with the name "%s". Check your ' . 'application configuration to configure your Doctrine entity managers.', $emName));
     }
     $em = $this->getContainer()->get($emServiceName);
     $dirOrFile = $input->getOption('fixtures');
     if ($dirOrFile) {
         $paths = is_array($dirOrFile) ? $dirOrFile : array($dirOrFile);
     } else {
         $paths = array();
         foreach ($this->getApplication()->getKernel()->getBundles() as $bundle) {
             $paths[] = $bundle->getPath() . '/DataFixtures/ORM';
         }
     }
     $loader = new DataFixturesLoader($this->getContainer());
     foreach ($paths as $path) {
         if (is_dir($path)) {
             $loader->loadFromDirectory($path);
         }
     }
     $fixtures = $loader->getFixtures();
     if (!$fixtures) {
         throw new InvalidArgumentException(sprintf('Could not find any fixtures to load in: %s', "\n\n- " . implode("\n- ", $paths)));
     }
     $purger = new ORMPurger($em);
     $executor = new ORMExecutor($em, $purger);
     $executor->setLogger(function ($message) use($output) {
         $output->writeln(sprintf('  <comment>></comment> <info>%s</info>', $message));
     });
     $executor->execute($fixtures, $input->getOption('append'));
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $em = $this->getEntityManager();
     if ($input->isInteractive() && !$input->getOption('append')) {
         if (!$this->askConfirmation($input, $output, '<question>Careful, database will be purged. Do you want to continue y/N ?</question>', false)) {
             return;
         }
     }
     $app = $this->getApp();
     $path = $app->getApplicationBase($app->getAppNamespace()) . '/DataFixture';
     $loader = new DataFixturesLoader();
     $loader->loadFromDirectory($path);
     $fixtures = $loader->getFixtures();
     if (!$fixtures) {
         throw new InvalidArgumentException(sprintf('Could not find any fixtures to load in: %s', "\n\n- {$path}"));
     }
     foreach ($fixtures as $fixture) {
         if ($fixture instanceof ContainerAwareInterface) {
             $fixture->setContainer($this->getContainer());
         }
     }
     $purger = new ORMPurger($em);
     if ($input->getOption('truncate-only')) {
         $purger->setPurgeMode(ORMPurger::PURGE_MODE_TRUNCATE);
         $purger->purge();
         exit(0);
     }
     $purger->setPurgeMode($input->getOption('truncate') ? ORMPurger::PURGE_MODE_TRUNCATE : ORMPurger::PURGE_MODE_DELETE);
     $executor = new ORMExecutor($em, $purger);
     $executor->setLogger(function ($message) use($output) {
         $output->writeln(sprintf('  <comment>></comment> <info>%s</info>', $message));
     });
     $executor->execute($fixtures, $input->getOption('append'));
 }
Exemple #5
0
 /**
  * Executes the current command.
  *
  * This method is not abstract because you can use this class
  * as a concrete class. In this case, instead of defining the
  * execute() method, you set the code to execute by passing
  * a Closure to the setCode() method.
  *
  * @param InputInterface $input An InputInterface instance
  * @param OutputInterface $output An OutputInterface instance
  *
  * @return null|int null or 0 if everything went fine, or an error code
  *
  * @throws LogicException When this abstract method is not implemented
  *
  * @see setCode()
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (empty($this->fixtures)) {
         $output->writeln('No fixtures found.');
         return -1;
     }
     $loader = new Loader();
     foreach ($this->fixtures as $fixture) {
         $loader->addFixture($fixture);
     }
     $purger = new ORMPurger($this->em);
     $executor = new ORMExecutor($this->em, $purger);
     $executor->setLogger(function ($message) use($output) {
         $output->writeln(sprintf('  <comment>></comment> <info>%s</info>', $message));
     });
     /** @var QuestionHelper $questionHelper */
     $questionHelper = $this->getHelper('question');
     $question = new ConfirmationQuestion('WARNING! Database will be purged before loading initialization data. Do you want to continue?', false);
     if (!$questionHelper->ask($input, $output, $question)) {
         $output->writeln('CMS initialization has been CANCELED!');
         return;
     }
     try {
         $executor->execute($loader->getFixtures());
         $output->writeln('Basic CMS data has been SUCCESSFULLY loaded!');
         return 0;
     } catch (\Exception $e) {
         $output->writeLn("That's bad. An Error occurred: <error>{$e->getMessage()}</error>");
         return -1;
     }
 }
 /**
  * {@inheritDoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $app = $this->getApplication()->getApp();
     $em = $app['em'];
     $dirOrFile = $input->getOption('fixtures');
     if ($dirOrFile) {
         $paths = is_array($dirOrFile) ? $dirOrFile : array($dirOrFile);
     } else {
         $paths = isset($app['em.fixtures']) ? $app['em.fixtures'] : array();
     }
     $loader = new Loader();
     foreach ($paths as $path) {
         if (is_dir($path)) {
             $loader->loadFromDirectory($path);
         }
     }
     $fixtures = $loader->getFixtures();
     if (!$fixtures) {
         throw new InvalidArgumentException(sprintf('Could not find any fixtures to load in: %s', "\n\n- " . implode("\n- ", $paths)));
     }
     $purger = new ORMPurger($em);
     $purger->setPurgeMode($input->getOption('purge-with-truncate') ? ORMPurger::PURGE_MODE_TRUNCATE : ORMPurger::PURGE_MODE_DELETE);
     $executor = new ORMExecutor($em, $purger);
     $executor->setLogger(function ($message) use($output) {
         $output->writeln(sprintf('  <comment>></comment> <info>%s</info>', $message));
     });
     $executor->execute($fixtures, $input->getOption('append'));
 }
 /**
  * Napolni podatke iz Fixtures
  */
 public function populateTestAction()
 {
     $logger = function ($message) {
         echo $message . PHP_EOL;
     };
     $em = $this->serviceLocator->get("\\Doctrine\\ORM\\EntityManager");
     $config = new Config($this->serviceLocator->get('config'));
     $loader = new Loader();
     $fixtures = isset($config->test_fixtures) ? $config->test_fixtures : [];
     $fixturename = $this->params('fixturename');
     if (!empty($fixturename)) {
         foreach ($fixtures as $dir) {
             $loader->loadFromFile($dir . '/' . $fixturename . 'Fixture.php');
             /**
              * če je dependent naj ne izvede nobenega
              */
             if (count($loader->getFixtures()) > 1) {
                 throw new \InvalidArgumentException('Loadanih več fixtur-jev -verjetno zaradi dependencies. Kot parameter možen le fixture brez odvisnosti.');
             }
         }
     } else {
         foreach ($fixtures as $dir) {
             $loader->loadFromDirectory($dir);
         }
     }
     $executor = new ORMExecutor($em);
     $executor->setLogger($logger);
     $executor->execute($loader->getFixtures(), true);
 }
 private function loadFixtures(OutputInterface $output, EntityManager $em, array $loaded)
 {
     $logger = function ($message) use($output) {
         $output->writeln(sprintf('  <comment>></comment> <info>%s</info>', $message));
     };
     $executor = new ORMExecutor($em);
     $paths = [];
     foreach ($this->getApplication()->getKernel()->getBundles() as $bundle) {
         $paths[] = $bundle->getPath() . '/Fixture';
     }
     $loader = new DataFixturesLoader($this->getContainer());
     foreach ($paths as $path) {
         if (is_dir($path)) {
             $loader->loadFromDirectory($path);
         }
     }
     $env = $this->getContainer()->getParameter('kernel.environment');
     $output->writeln("Loading <comment>fixtures</comment>...");
     $has = array_map(function (Fixture $fixture) {
         return $fixture->getName();
     }, $loaded);
     $fixtures = array_filter($loader->getFixtures(), function (FixtureInterface $fixture) use($has) {
         return !in_array(get_class($fixture), $has);
     });
     if (!$fixtures) {
         $output->writeln("  Could not find any new <comment>fixtures</comment> to load..");
         return [];
     }
     $executor->setLogger($logger);
     $executor->execute($fixtures, true);
     return $fixtures;
 }
 /**
  * {@inheritDoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->container = $this->getContainer();
     $output->writeln("<comment>Updating...</comment>\n");
     $em = $this->container->get('doctrine.orm.entity_manager');
     $loader = new ContainerAwareLoader($this->container);
     $loader->loadFromDirectory($input->getOption('fixtures'));
     $purger = new ORMPurger($em);
     $executor = new ORMExecutor($em, $purger);
     $executor->setLogger(function ($message) use($output) {
         $output->writeln(sprintf('  <comment>></comment> <info>%s</info>', $message));
     });
     $executor->execute($loader->getFixtures(), true);
 }
 /**
  * Loads the data fixtures passed as array.
  *
  * @param array    $fixtureClasses
  * @param callable $executorLogFunction
  *
  * @throws \InvalidArgumentException If the fixture class does not exist.
  */
 public function applyFixtures(array $fixtureClasses, callable $executorLogFunction = null)
 {
     $loader = new Loader();
     foreach ($fixtureClasses as $fixtureClass) {
         if (!class_exists($fixtureClass)) {
             throw new \InvalidArgumentException(sprintf('Fixture class "%s" does not exist!', $fixtureClass));
         }
         $loader->addFixture(new $fixtureClass());
     }
     $purger = new ORMPurger($this->entityManager);
     $executor = new ORMExecutor($this->entityManager, $purger);
     if (null !== $executorLogFunction) {
         $executor->setLogger($executorLogFunction);
     }
     $executor->execute($loader->getFixtures());
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('Loading demo data ...');
     $container = $this->getContainer();
     $loader = new ContainerAwareLoader($container);
     foreach ($container->get('kernel')->getBundles() as $bundle) {
         if (is_dir($path = $bundle->getPath() . '/DataFixtures/Demo')) {
             $loader->loadFromDirectory($path);
         }
     }
     $executor = new ORMExecutor($container->get('doctrine.orm.entity_manager'));
     $executor->setLogger(function ($message) use($output) {
         $output->writeln(sprintf('  <comment>></comment> <info>%s</info>', $message));
     });
     $executor->execute($loader->getFixtures(), true);
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var $doctrine \Doctrine\Common\Persistence\ManagerRegistry */
     $doctrine = $this->getContainer()->get('doctrine');
     $em = $doctrine->getManager($input->getOption('em'));
     if ($input->isInteractive() && !$input->getOption('append')) {
         $dialog = $this->getHelperSet()->get('dialog');
         if (!$dialog->askConfirmation($output, '<question>Careful, database will be purged. Do you want to continue Y/N ?</question>', false)) {
             return;
         }
     }
     $dirOrFile = $input->getOption('fixtures');
     if ($dirOrFile) {
         $paths = is_array($dirOrFile) ? $dirOrFile : array($dirOrFile);
     } else {
         $paths = array();
         foreach ($this->getApplication()->getKernel()->getBundles() as $bundle) {
             $paths[] = $bundle->getPath() . '/DataFixtures/ORM';
         }
     }
     $loader = new DataFixturesLoader($this->getContainer());
     foreach ($paths as $path) {
         if (is_dir($path)) {
             $loader->loadFromDirectory($path);
         }
     }
     $fixtures = $loader->getFixtures();
     if (!$fixtures) {
         throw new InvalidArgumentException(sprintf('Could not find any fixtures to load in: %s', "\n\n- " . implode("\n- ", $paths)));
     }
     $purger = new ORMPurger($em);
     $purger->setPurgeMode($input->getOption('purge-with-truncate') ? ORMPurger::PURGE_MODE_TRUNCATE : ORMPurger::PURGE_MODE_DELETE);
     $executor = new ORMExecutor($em, $purger);
     $executor->setLogger(function ($message) use($output) {
         $output->writeln(sprintf('  <comment>></comment> <info>%s</info>', $message));
     });
     $executor->execute($fixtures, $input->getOption('append'));
     // Serialize reference repository to a file. So fixtures will be accessible by names inside functional tests.
     $referenceRepositoryFile = $this->getContainer()->getParameter('fixtures.reference_repository_path');
     $serializedReferenceRepository = (new FixtureReferenceRepositorySerializer())->serialize($executor->getReferenceRepository());
     file_put_contents($referenceRepositoryFile, $serializedReferenceRepository);
     $output->writeln(sprintf('<info>Reference repository saved to:</info> <comment>%s</comment>', realpath($referenceRepositoryFile)));
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $em = $this->em;
     if ($input->isInteractive() && !$input->getOption('append')) {
         $dialog = $this->getHelperSet()->get('dialog');
         if (!$dialog->askConfirmation($output, '<question>Careful, database will be purged. Do you want to continue Y/N ?</question>', false)) {
             return;
         }
     }
     $dirOrFile = $input->getOption('fixtures');
     if ($dirOrFile) {
         $paths = is_array($dirOrFile) ? $dirOrFile : array($dirOrFile);
     } else {
         $paths = array();
         foreach (glob(APPPATH . 'modules/*/fixtures', GLOB_ONLYDIR) as $m) {
             $paths[] = $m;
         }
     }
     $loader = new Loader();
     foreach ($paths as $path) {
         if (is_dir($path)) {
             $loader->loadFromDirectory($path);
         }
     }
     $fixtures = $loader->getFixtures();
     if (!$fixtures) {
         throw new InvalidArgumentException(sprintf('Could not find any fixtures to load in: %s', "\n\n- " . implode("\n- ", $paths)));
     }
     $purger = new ORMPurger($em);
     // $purger->setPurgeMode($input->getOption('purge-with-truncate') ? ORMPurger::PURGE_MODE_TRUNCATE : ORMPurger::PURGE_MODE_DELETE);
     $executor = new ORMExecutor($em, $purger);
     $executor->setLogger(function ($message) use($output) {
         $output->writeln(sprintf('  <comment>></comment> <info>%s</info>', $message));
     });
     $executor->execute($fixtures, $input->getOption('append'));
 }
 /**
  * Process fixtures
  *
  * @param InputInterface  $input
  * @param OutputInterface $output
  * @param array           $fixtures
  */
 protected function processFixtures(InputInterface $input, OutputInterface $output, $fixtures)
 {
     $output->writeln(sprintf('Loading "%s" data fixtures ...', $this->getTypeOfFixtures($input)));
     $executor = new ORMExecutor($this->getContainer()->get('doctrine.orm.entity_manager'));
     $executor->setLogger(function ($message) use($output) {
         $output->writeln(sprintf('  <comment>></comment> <info>%s</info>', $message));
     });
     $executor->execute($fixtures, true);
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var $doctrine \Doctrine\Common\Persistence\ManagerRegistry */
     $doctrine = $this->getContainer()->get('doctrine');
     $em = $doctrine->getManager($input->getOption('em'));
     if ($input->isInteractive() && !$input->getOption('append')) {
         if (!$this->askConfirmation($input, $output, '<question>Careful, database will be purged. Do you want to continue y/N ?</question>', false)) {
             return;
         }
     }
     if ($input->getOption('shard')) {
         if (!$em->getConnection() instanceof PoolingShardConnection) {
             throw new \LogicException(sprintf("Connection of EntityManager '%s' must implement shards configuration.", $input->getOption('em')));
         }
         $em->getConnection()->connect($input->getOption('shard'));
     }
     $dirOrFile = $input->getOption('fixtures');
     if ($dirOrFile) {
         $paths = is_array($dirOrFile) ? $dirOrFile : array($dirOrFile);
     } else {
         $paths = array();
         foreach ($this->getApplication()->getKernel()->getBundles() as $bundle) {
             $paths[] = $bundle->getPath() . '/DataFixtures/ORM';
         }
     }
     $loader = new DataFixturesLoader($this->getContainer());
     foreach ($paths as $path) {
         if (is_dir($path)) {
             $loader->loadFromDirectory($path);
         } elseif (is_file($path)) {
             $loader->loadFromFile($path);
         }
     }
     $fixtures = $loader->getFixtures();
     if (!$fixtures) {
         throw new InvalidArgumentException(sprintf('Could not find any fixtures to load in: %s', "\n\n- " . implode("\n- ", $paths)));
     }
     $purger = new ORMPurger($em);
     $purger->setPurgeMode($input->getOption('purge-with-truncate') ? ORMPurger::PURGE_MODE_TRUNCATE : ORMPurger::PURGE_MODE_DELETE);
     $executor = new ORMExecutor($em, $purger);
     $executor->setLogger(function ($message) use($output) {
         $output->writeln(sprintf('  <comment>></comment> <info>%s</info>', $message));
     });
     $executor->execute($fixtures, $input->getOption('append'), $input->getOption('multiple-transactions'));
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $file = $input->getArgument('file');
     $em = $this->getContainer()->get('doctrine')->getManager();
     if (!$this->askConfirmation($input, $output, '<question>Careful, database will be purged. Do you want to continue y/N ?</question>', false)) {
         return;
     }
     $purger = new ORMPurger($em);
     $purger->setPurgeMode(ORMPurger::PURGE_MODE_DELETE);
     $executor = new ORMExecutor($em, $purger);
     $executor->setLogger(function ($message) use($output) {
         $output->writeln(sprintf('  <comment>></comment> <info>%s</info>', $message));
     });
     $executor->purge();
     // Load users
     $stream = fopen($file, 'r');
     while ($line = fgets($stream)) {
         if (strpos($line, 'COPY multipass_users (id') !== FALSE) {
             break;
         }
     }
     $userManager = $this->getUserManager();
     $userAdmin = $userManager->createUser();
     $userAdmin->setPlainPassword('admin');
     $userAdmin->setEnabled(true);
     $userAdmin->setEmail('*****@*****.**');
     $userAdmin->setRoles(array('ROLE_SUPER_ADMIN'));
     $userAdmin->setFirstname('Romain');
     $userAdmin->setLastname('Coeur');
     $userAdmin->setPhone('0628974930');
     $userManager->updateUser($userAdmin);
     $users = array('admin' => $userAdmin);
     while ($line = fgets($stream)) {
         $data = explode('	', $line);
         if ($data[0] == "\\.\n") {
             break;
         }
         $entity = $userManager->createUser();
         $entity->setUsername($data[1]);
         $entity->setUsernameCanonical($data[1]);
         $entity->setEmail($data[1]);
         $entity->setEmailCanonical($data[1]);
         $entity->setEnabled(true);
         $entity->setPlainPassword('wild1234');
         $entity->setPassword('9908e42e69c19bc0e6c0ce1bf05b381fbc94ca10aa7e6b648815d676248f8a3fe2ee124f7d9d375e9f909036e45cc9e766e3c9369655c1db1f331e71c17bc2c9');
         $userManager->updateUser($entity);
         $users[$data[0]] = $entity;
     }
     $em->flush();
     $output->writeln(sprintf('  <comment>></comment> <info>%s users loaded</info>', count($users)));
     // Add home data to users
     rewind($stream);
     while ($line = fgets($stream)) {
         if (strpos($line, 'COPY multipass_homes (id') !== FALSE) {
             break;
         }
     }
     $nb = 0;
     while ($line = fgets($stream)) {
         $data = explode('	', $line);
         if ($data[0] == "\\.\n") {
             break;
         }
         $user = $users[$data[11]];
         $user->setFirstname($data[1]);
         $user->setLastname($data[2]);
         $user->setPhone($data[3]);
         $user->setTelephoneSecondaire($data[4]);
         $user->setAdresse($data[5]);
         $user->setCodePostal($data[6]);
         $user->setCommune($data[7]);
         $user->setModeDePaiement($data[8]);
         $user->setGender($data[9]);
         $user->setCaf($data[10]);
         $em->persist($user);
         $nb++;
     }
     $em->flush();
     $output->writeln(sprintf('  <comment>></comment> <info>%s users updated</info>', $nb));
     // Load schools
     rewind($stream);
     while ($line = fgets($stream)) {
         if (strpos($line, 'COPY multipass_schools (id') !== FALSE) {
             break;
         }
     }
     $schools = array();
     while ($line = fgets($stream)) {
         $data = explode('	', $line);
         if ($data[0] == "\\.\n") {
             break;
         }
         $entity = new School();
         $entity->setName($data[1]);
         $entity->setAdress($data[2]);
         $em->persist($entity);
         $schools[$data[0]] = $entity;
     }
     $em->flush();
     $output->writeln(sprintf('  <comment>></comment> <info>%s schools loaded</info>', count($schools)));
     // Load divisions
     rewind($stream);
     while ($line = fgets($stream)) {
         if (strpos($line, 'COPY multipass_classrooms (id') !== FALSE) {
             break;
         }
     }
     $divisions = array();
     while ($line = fgets($stream)) {
         $data = explode('	', $line);
         if ($data[0] == "\\.\n") {
             break;
         }
         $entity = new Division();
         $entity->setSchool($schools[$data[10]]);
         $gradeAndTeacher = explode(' DE ', $data[1]);
         $entity->setGrade($gradeAndTeacher[0]);
         $entity->setHeadTeacher($gradeAndTeacher[1]);
         $em->persist($entity);
         $divisions[$data[0]] = $entity;
     }
     $em->flush();
     $output->writeln(sprintf('  <comment>></comment> <info>%s divisions loaded</info>', count($divisions)));
     // Load children
     rewind($stream);
     while ($line = fgets($stream)) {
         if (strpos($line, 'COPY multipass_children (id') !== FALSE) {
             break;
         }
     }
     $nb = 0;
     while ($line = fgets($stream)) {
         $data = explode('	', $line);
         if ($data[0] == "\\.\n") {
             break;
         }
         if ($data[5] == '\\N') {
             continue;
         }
         $entity = new Eleve();
         $entity->setPrenom($data[1]);
         $entity->setNom($data[2]);
         $entity->setDateDeNaissance(new \DateTime($data[3]));
         $entity->setUser($users[$data[4]]);
         $entity->setDivision($divisions[$data[5]]);
         $habits = array();
         if ($data[8] == 't') {
             $habits[] = "lundi";
         }
         if ($data[9] == 't') {
             $habits[] = "mardi";
         }
         if ($data[10] == 't') {
             $habits[] = "jeudi";
         }
         if ($data[11] == 't') {
             $habits[] = "vendredi";
         }
         $entity->setHabits($habits);
         $entity->setAllergie($data[13]);
         $entity->setRegimeSansPorc($data[14]);
         $em->persist($entity);
         $nb++;
     }
     $em->flush();
     $output->writeln(sprintf('  <comment>></comment> <info>%s divisions loaded</info>', $nb));
     fclose($stream);
     $output->writeln(sprintf('<info>done</info>'));
 }
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  * 
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     if (!($searchPaths = $input->getArgument('fixtures'))) {
         $searchPaths = $this->getSearchPaths();
     }
     if (count($searchPaths) === 0) {
         $io->error('No search paths could be determinened.');
         return;
     }
     $io->section('Determening ORM paths');
     $io->listing($searchPaths);
     $io->section('Registering fixtures');
     $registry = new FixtureRegistry($this->getContainer());
     foreach ($searchPaths as $path) {
         $registry->loadFromPath($path);
     }
     $fixtures = $registry->getFixtures();
     if (!$fixtures) {
         $io->error('Unable to find any fixtures within the following search paths.');
         $io->listing($searchPaths);
         return;
     }
     if ($input->isInteractive() && !$io->confirm('Do you want to begin fixture loading', false)) {
         return;
     }
     $purger = new ORMPurger($this->em);
     $purger->setPurgeMode(ORMPurger::PURGE_MODE_TRUNCATE);
     $executor = new ORMExecutor($this->em, $purger);
     $executor->setLogger(function ($message) use($output) {
         $output->writeln(sprintf('  <comment>></comment> <info>%s</info>', $message));
     });
     $io->section('Importing fixtures');
     $executor->execute($fixtures, true);
     $io->success('Complete!');
     /*
     if ($input->isInteractive() && !$input->getOption('append')) {
         if (!$this->askConfirmation($input, $output, '<question>Careful, database will be purged. Do you want to continue y/N ?</question>', false)) {
             return;
         }
     }
     */
 }