diff --git a/src/Composer/Command/InitCommand.php b/src/Composer/Command/InitCommand.php index 749e7ab00..d20fdedaa 100644 --- a/src/Composer/Command/InitCommand.php +++ b/src/Composer/Command/InitCommand.php @@ -13,7 +13,6 @@ namespace Composer\Command; use Composer\Json\JsonFile; -use Composer\Command\Helper\DialogHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -70,7 +69,7 @@ EOT protected function execute(InputInterface $input, OutputInterface $output) { - $dialog = $this->getDialogHelper(); + $dialog = $this->getHelperSet()->get('dialog'); $whitelist = array('name', 'description', 'author', 'require'); @@ -125,7 +124,7 @@ EOT { $git = $this->getGitConfig(); - $dialog = $this->getDialogHelper(); + $dialog = $this->getHelperSet()->get('dialog'); $dialog->writeSection($output, 'Welcome to the Composer config generator'); // namespace @@ -208,16 +207,6 @@ EOT $input->setOption('require', $requirements); } - protected function getDialogHelper() - { - $dialog = $this->getHelperSet()->get('dialog'); - if (!$dialog || get_class($dialog) !== 'Composer\Command\Helper\DialogHelper') { - $this->getHelperSet()->set($dialog = new DialogHelper()); - } - - return $dialog; - } - protected function findPackages($name) { $composer = $this->getComposer(); @@ -243,7 +232,7 @@ EOT protected function determineRequirements(InputInterface $input, OutputInterface $output) { - $dialog = $this->getDialogHelper(); + $dialog = $this->getHelperSet()->get('dialog'); $prompt = $dialog->getQuestion('Search for a package', false, ':'); $requires = $input->getOption('require') ?: array(); diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php index 3b3979770..fe6b6cb13 100644 --- a/src/Composer/Console/Application.php +++ b/src/Composer/Console/Application.php @@ -20,6 +20,7 @@ use Symfony\Component\Console\Formatter\OutputFormatter; use Symfony\Component\Console\Formatter\OutputFormatterStyle; use Symfony\Component\Finder\Finder; use Composer\Command; +use Composer\Command\Helper\DialogHelper; use Composer\Composer; use Composer\Factory; use Composer\IO\IOInterface; @@ -115,4 +116,16 @@ class Application extends BaseApplication $this->add(new Command\SelfUpdateCommand()); } } + + /** + * {@inheritDoc} + */ + protected function getDefaultHelperSet() + { + $helperSet = parent::getDefaultHelperSet(); + + $helperSet->set(new DialogHelper()); + + return $helperSet; + } }