Skip to content

Commit

Permalink
2547: Fixed code style
Browse files Browse the repository at this point in the history
  • Loading branch information
cableman committed Dec 13, 2024
1 parent 1c96241 commit 70b0103
Showing 1 changed file with 32 additions and 34 deletions.
66 changes: 32 additions & 34 deletions src/Command/EventDeleteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,51 +84,49 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
}

if (null !== $feedId) {
$feed = $this->feedRepository->find($feedId);
if (!$feed) {
$io->error(sprintf('Feed with ID %s not found', $feedId));
$feed = $this->feedRepository->find($feedId);
if (!$feed) {
$io->error(sprintf('Feed with ID %s not found', $feedId));

return Command::FAILURE;
}

$name = $feed->getName() ?? 'UNKNOWN';
$question = sprintf('Delete ALL events from feed %s: %s?', $feedId, $name);

if ($io->confirm($question, false)) {
try {
$events = $feed->getEvents();
$count = count($events);
return Command::FAILURE;
}

$progressBar = new ProgressBar($output, $count);
$progressBar->start();
$progressBar->setMessage(sprintf('Deleting events from feed %s: %s?', $feedId, $name));
$progressBar->display();
$name = $feed->getName() ?? 'UNKNOWN';
$question = sprintf('Delete ALL events from feed %s: %s?', $feedId, $name);

foreach ($events as $event) {
$image = $event->getImage()?->getLocal();
if (null !== $image) {
$this->imageCacheManager->remove($image);
}
if ($io->confirm($question, false)) {
try {
$events = $feed->getEvents();
$count = count($events);

$this->eventRepository->remove($event, true);
$progressBar = new ProgressBar($output, $count);
$progressBar->start();
$progressBar->setMessage(sprintf('Deleting events from feed %s: %s?', $feedId, $name));
$progressBar->display();

$progressBar->advance();
foreach ($events as $event) {
$image = $event->getImage()?->getLocal();
if (null !== $image) {
$this->imageCacheManager->remove($image);
}

$progressBar->finish();

return Command::SUCCESS;
} catch (\Throwable $e) {
$io->error(sprintf('Error deleting events with ID %s: %s', $feedId, $e->getMessage()));
$this->eventRepository->remove($event, true);

return Command::FAILURE;
$progressBar->advance();
}
} else {
$io->info('Events not deleted');

return Command::INVALID;
$progressBar->finish();

return Command::SUCCESS;
} catch (\Throwable $e) {
$io->error(sprintf('Error deleting events with ID %s: %s', $feedId, $e->getMessage()));

return Command::FAILURE;
}
} else {
$io->info('Events not deleted');

return Command::INVALID;
}
}
}

0 comments on commit 70b0103

Please sign in to comment.