/**
  * {@inheritdoc}
  *
  * \RuntimeException Unsupported Application type
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var Application $application */
     $application = $this->getApplication();
     if (false === $application instanceof Application) {
         throw new \RuntimeException('Expected Symfony\\Bundle\\FrameworkBundle\\Console\\Application application.');
     }
     $environment = $input->getOption('env');
     $manager = $this->doctrine->getManager($input->getOption('manager'));
     // Warn the user that the database will be purged
     // Ask him to confirm his choice
     if ($input->isInteractive() && !$input->getOption('append')) {
         if (false === $this->askConfirmation($input, $output, '<question>Careful, database will be purged. Do you want to continue y/N ?</question>', false)) {
             return;
         }
     }
     // Get bundles
     $bundles = $input->getOption('bundle');
     if (true === empty($bundles)) {
         $bundles = $application->getKernel()->getBundles();
     } else {
         $bundles = $this->finder->resolveBundles($application, $bundles);
     }
     // Get fixtures
     $fixtures = $this->finder->getFixtures($application->getKernel(), $bundles, $environment);
     $output->writeln(sprintf('  <comment>></comment> <info>%s</info>', 'fixtures found:'));
     foreach ($fixtures as $fixture) {
         $output->writeln(sprintf('      <comment>-</comment> <info>%s</info>', $fixture));
     }
     // Get data loaders to generate the new loader
     // Have to create a new one to add each data loader as a provider
     $loaders = $this->finder->getDataLoaders($bundles, $environment);
     $newLoader = new Loader(new ProcessorChain($this->loader->getProcessors()), new ProviderChain(array_merge($this->loader->getOptions()['providers'], $loaders)), $this->loader->getOptions()['locale'], $this->loader->getOptions()['seed'], $this->loader->getOptions()['persist_once'], true === isset($this->loader->getOptions()['logger']) ? $this->loader->getOptions()['logger'] : null);
     // Get executor
     $purger = new ORMPurger($manager);
     $purger->setPurgeMode($input->getOption('purge-with-truncate') ? ORMPurger::PURGE_MODE_TRUNCATE : ORMPurger::PURGE_MODE_DELETE);
     $executor = new ORMExecutor($manager, $newLoader, $purger);
     $executor->setLogger(function ($message) use($output) {
         $output->writeln(sprintf('  <comment>></comment> <info>%s</info>', $message));
     });
     // Purge database and load fixtures
     $executor->execute($fixtures, $input->getOption('append'));
     $output->writeln(sprintf('  <comment>></comment> <info>%s</info>', 'fixtures loaded'));
 }