Cleanup up the restore command and sort the input files

This commit is contained in:
Tim 2022-10-19 14:49:48 +02:00
parent 3920ed4244
commit 0b6b48d5ec

View File

@ -40,10 +40,11 @@ class RestoreDatabaseCommand extends Command
if (!$fileName){ if (!$fileName){
$finder = new Finder(); $finder = new Finder();
$finder->in(__DIR__ . '/../..'); $finder->in(__DIR__ . '/../..');
$files = [sprintf('%s_backup.sql', $db)]; $files = [];
foreach ($finder->files()->name('*_backup.sql') as $file) { foreach ($finder->files()->name('*_backup.sql') as $file) {
$files[] = $file->getFilename(); $files[] = $file->getFilename();
} }
sort($files);
$selectQuestion = new ChoiceQuestion('Backup name (*_backup.sql): ', $files); $selectQuestion = new ChoiceQuestion('Backup name (*_backup.sql): ', $files);
$fileName = $question->ask($input, $output, $selectQuestion); $fileName = $question->ask($input, $output, $selectQuestion);
} }