execute() public method

Load the given fixture classes.
public execute ( array $fixtures, mixed $purge = true, mixed $initialize = true, Symfony\Component\Console\Output\OutputInterface $output = null )
$fixtures array
$purge mixed
$initialize mixed
$output Symfony\Component\Console\Output\OutputInterface
Example #1
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $noInitialize = $input->getOption('no-initialize');
     $append = $input->getOption('append');
     if ($input->isInteractive() && !$append) {
         $dialog = $this->getHelperSet()->get('dialog');
         $confirmed = $dialog->askConfirmation($output, '<question>Careful, database will be purged. Do you want to continue Y/N ?</question>', false);
         if (!$confirmed) {
             return 0;
         }
     }
     $paths = $input->getOption('fixtures');
     $candidatePaths = [];
     if (!$paths) {
         $paths = [];
         foreach ($this->kernel->getBundles() as $bundle) {
             $candidatePath = $bundle->getPath() . '/DataFixtures/Document';
             $candidatePaths[] = $candidatePath;
             if (file_exists($candidatePath)) {
                 $paths[] = $candidatePath;
             }
         }
     }
     if (empty($paths)) {
         $output->writeln('<info>Could not find any candidate fixture paths.</info>');
         if ($input->getOption('verbose')) {
             $output->writeln(sprintf('Looked for: </comment>%s<comment>"</comment>', implode('"<comment>", "</comment>', $candidatePaths)));
         }
         return 0;
     }
     $fixtures = $this->loader->load($paths);
     $this->executor->execute($fixtures, false === $append, false === $noInitialize, $output);
     $output->writeln('');
     $output->writeln(sprintf('<info>Done. Executed </info>%s</info><info> fixtures.</info>', count($fixtures)));
 }