Skip to content

Commit

Permalink
Fix option value check
Browse files Browse the repository at this point in the history
InputOption::VALUE_NONE options return either true or false, never null
  • Loading branch information
Pryx authored and f3l1x committed Oct 3, 2023
1 parent 63f1fe5 commit c574666
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Command/LoadDataFixturesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$em = $this->managerRegistry->getManager(is_string($input->getOption('em')) ? $input->getOption('em') : null);
assert($em instanceof EntityManagerInterface);

if ($input->getOption('append') !== null) {
if ($input->getOption('append') === false) {
if (!$ui->confirm(sprintf('Careful, database "%s" will be purged. Do you want to continue?', $em->getConnection()->getDatabase()), !$input->isInteractive())) {
return 0;
}
Expand All @@ -89,13 +89,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$purgeTruncate = $input->getOption('purge-with-truncate');
$purger = new ORMPurger($em);
$purger->setPurgeMode($purgeTruncate !== null ? ORMPurger::PURGE_MODE_TRUNCATE : ORMPurger::PURGE_MODE_DELETE);
$purger->setPurgeMode($purgeTruncate !== false ? ORMPurger::PURGE_MODE_TRUNCATE : ORMPurger::PURGE_MODE_DELETE);

$executor = new ORMExecutor($em, $purger);
$executor->setLogger(static function ($message) use ($ui): void {
$ui->text(sprintf(' <comment>></comment> <info>%s</info>', $message));
});
$executor->execute($fixtures, $input->getOption('append') !== null);
$executor->execute($fixtures, $input->getOption('append') !== false);

return 0;
}
Expand Down

0 comments on commit c574666

Please sign in to comment.