Update symfony to 6.3 and upgrade some classes

This commit is contained in:
Tim
2023-09-29 11:01:38 +02:00
parent 4fd5aac51a
commit 017249474f
5 changed files with 439 additions and 306 deletions

View File

@ -34,23 +34,28 @@ class RestoreDatabaseCommand extends Command
protected function execute(InputInterface $input, OutputInterface $output): int
{
$question = $this->getHelper('question');
$db = $this->getDatabaseName($input, $output);
$fileName = $input->getArgument('file');
if (!$fileName){
$finder = new Finder();
$finder->in(__DIR__ . '/../..');
$files = [];
foreach ($finder->files()->name('*_backup.sql') as $file) {
$files[] = $file->getFilename();
}
sort($files);
$selectQuestion = new ChoiceQuestion('Backup name (*_backup.sql): ', $files);
$fileName = $question->ask($input, $output, $selectQuestion);
$fileName = $this->getFileName($input, $output);
}
$this->bs->restore($db, $fileName);
return Command::SUCCESS;
}
private function getFileName(InputInterface $input, OutputInterface $output): string
{
$finder = new Finder();
$finder->in(__DIR__ . '/../..');
$files = [];
foreach ($finder->files()->name('*_backup.sql') as $file) {
$files[] = $file->getFilename();
}
sort($files);
$selectQuestion = new ChoiceQuestion('Backup name (*_backup.sql): ', $files);
$question = $this->getHelper('question');
return $question->ask($input, $output, $selectQuestion);
}
}

View File

@ -8,7 +8,9 @@ use Symfony\Component\Process\Process;
class BackupService
{
public function __construct(private DatabaseCredentials $credentials)
public function __construct(
private readonly DatabaseCredentials $credentials
)
{
}

View File

@ -10,7 +10,7 @@ class DatabaseService
private mysqli $conn;
public function __construct(
private MysqliConnection $service
private readonly MysqliConnection $service
)
{
$this->conn = $this->service->getConnection();