dbmanager/src/Service/Traits/SelectUserQuestion.php

22 lines
632 B
PHP

<?php
namespace App\Service\Traits;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ChoiceQuestion;
trait SelectUserQuestion
{
private function getUserName(InputInterface $input, OutputInterface $output): string
{
$question = $this->getHelper('question');
if (!$name = $input->getArgument('name')) {
$selectQuestion = new ChoiceQuestion('Database name: ', $this->db->listDatabases());
$name = $question->ask($input, $output, $selectQuestion);
}
return $name;
}
}