|
@@ -11,20 +11,15 @@
|
|
|
|
|
|
namespace Sonata\AdminBundle\Command;
|
|
|
|
|
|
-use Sensio\Bundle\GeneratorBundle\Command\Helper\DialogHelper;
|
|
|
-use Sensio\Bundle\GeneratorBundle\Command\Helper\QuestionHelper;
|
|
|
use Sonata\AdminBundle\Generator\AdminGenerator;
|
|
|
use Sonata\AdminBundle\Generator\ControllerGenerator;
|
|
|
use Sonata\AdminBundle\Manipulator\ServicesManipulator;
|
|
|
use Sonata\AdminBundle\Model\ModelManagerInterface;
|
|
|
-use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
|
|
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
|
|
use Symfony\Component\Console\Input\InputArgument;
|
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
|
use Symfony\Component\Console\Input\InputOption;
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
-use Symfony\Component\Console\Question\ConfirmationQuestion;
|
|
|
-use Symfony\Component\Console\Question\Question;
|
|
|
use Symfony\Component\DependencyInjection\Container;
|
|
|
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
|
|
|
use Symfony\Component\HttpKernel\KernelInterface;
|
|
@@ -33,7 +28,7 @@ use Symfony\Component\HttpKernel\KernelInterface;
|
|
|
* @author Marek Stipek <mario.dweller@seznam.cz>
|
|
|
* @author Simon Cosandey <simon.cosandey@simseo.ch>
|
|
|
*/
|
|
|
-class GenerateAdminCommand extends ContainerAwareCommand
|
|
|
+class GenerateAdminCommand extends QuestionableCommand
|
|
|
{
|
|
|
/**
|
|
|
* @var string[]
|
|
@@ -277,66 +272,6 @@ class GenerateAdminCommand extends ContainerAwareCommand
|
|
|
$output->writeln(sprintf("\n<error>%s</error>", $message));
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * @param InputInterface $input
|
|
|
- * @param OutputInterface $output
|
|
|
- * @param string $questionText
|
|
|
- * @param mixed $default
|
|
|
- * @param callable $validator
|
|
|
- *
|
|
|
- * @return mixed
|
|
|
- */
|
|
|
- private function askAndValidate(InputInterface $input, OutputInterface $output, $questionText, $default, $validator)
|
|
|
- {
|
|
|
- $questionHelper = $this->getQuestionHelper();
|
|
|
-
|
|
|
- // NEXT_MAJOR: Remove this BC code for SensioGeneratorBundle 2.3/2.4 after dropping support for Symfony 2.3
|
|
|
- if ($questionHelper instanceof DialogHelper) {
|
|
|
- return $questionHelper->askAndValidate(
|
|
|
- $output,
|
|
|
- $questionHelper->getQuestion($questionText, $default),
|
|
|
- $validator,
|
|
|
- false,
|
|
|
- $default
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- $question = new Question($questionHelper->getQuestion($questionText, $default), $default);
|
|
|
-
|
|
|
- $question->setValidator($validator);
|
|
|
-
|
|
|
- return $questionHelper->ask($input, $output, $question);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @param InputInterface $input
|
|
|
- * @param OutputInterface $output
|
|
|
- * @param string $questionText
|
|
|
- * @param string $default
|
|
|
- * @param string $separator
|
|
|
- *
|
|
|
- * @return string
|
|
|
- */
|
|
|
- private function askConfirmation(InputInterface $input, OutputInterface $output, $questionText, $default, $separator)
|
|
|
- {
|
|
|
- $questionHelper = $this->getQuestionHelper();
|
|
|
-
|
|
|
- // NEXT_MAJOR: Remove this BC code for SensioGeneratorBundle 2.3/2.4 after dropping support for Symfony 2.3
|
|
|
- if ($questionHelper instanceof DialogHelper) {
|
|
|
- $question = $questionHelper->getQuestion($questionText, $default, $separator);
|
|
|
-
|
|
|
- return $questionHelper->askConfirmation($output, $question, ($default === 'no' ? false : true));
|
|
|
- }
|
|
|
-
|
|
|
- $question = new ConfirmationQuestion($questionHelper->getQuestion(
|
|
|
- $questionText,
|
|
|
- $default,
|
|
|
- $separator
|
|
|
- ), ($default === 'no' ? false : true));
|
|
|
-
|
|
|
- return $questionHelper->ask($input, $output, $question);
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* @return string
|
|
|
*
|
|
@@ -415,29 +350,4 @@ class GenerateAdminCommand extends ContainerAwareCommand
|
|
|
|
|
|
return $application->getKernel();
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * @return QuestionHelper|DialogHelper
|
|
|
- */
|
|
|
- private function getQuestionHelper()
|
|
|
- {
|
|
|
- // NEXT_MAJOR: Remove this BC code for SensioGeneratorBundle 2.3/2.4 after dropping support for Symfony 2.3
|
|
|
- if (class_exists('Sensio\Bundle\GeneratorBundle\Command\Helper\DialogHelper')) {
|
|
|
- $questionHelper = $this->getHelper('dialog');
|
|
|
-
|
|
|
- if (!$questionHelper instanceof DialogHelper) {
|
|
|
- $questionHelper = new DialogHelper();
|
|
|
- $this->getHelperSet()->set($questionHelper);
|
|
|
- }
|
|
|
- } else {
|
|
|
- $questionHelper = $this->getHelper('question');
|
|
|
-
|
|
|
- if (!$questionHelper instanceof QuestionHelper) {
|
|
|
- $questionHelper = new QuestionHelper();
|
|
|
- $this->getHelperSet()->set($questionHelper);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return $questionHelper;
|
|
|
- }
|
|
|
}
|