X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=vendor%2Fdrupal%2Fconsole-core%2Fsrc%2FStyle%2FDrupalStyle.php;h=60edb99f64700efbda57e7ff3d74d3e6b80dd777;hb=4e1bfbf98b844da83b18aca92ef00f11a4735806;hp=c626d216ee5c7d9a86116ab27abccbd296d6cacd;hpb=eba34333e3c89f208d2f72fa91351ad019a71583;p=yaffs-website diff --git a/vendor/drupal/console-core/src/Style/DrupalStyle.php b/vendor/drupal/console-core/src/Style/DrupalStyle.php index c626d216e..60edb99f6 100644 --- a/vendor/drupal/console-core/src/Style/DrupalStyle.php +++ b/vendor/drupal/console-core/src/Style/DrupalStyle.php @@ -40,16 +40,16 @@ class DrupalStyle extends SymfonyStyle * @param string $question * @param array $choices * @param mixed $default - * @param bool $allowEmpty + * @param bool $skipValidation * * @return string */ - public function choiceNoList($question, array $choices, $default = null, $allowEmpty = false) - { - if ($allowEmpty) { - $default = ' '; - } - + public function choiceNoList( + $question, + array $choices, + $default = null, + $skipValidation = false + ) { if (is_null($default)) { $default = current($choices); } @@ -63,7 +63,16 @@ class DrupalStyle extends SymfonyStyle $default = $values[$default]; } - return trim($this->askChoiceQuestion(new ChoiceQuestion($question, $choices, $default))); + $choiceQuestion = new ChoiceQuestion($question, $choices, $default); + if ($skipValidation) { + $choiceQuestion->setValidator( + function ($answer) { + return $answer; + } + ); + } + + return trim($this->askChoiceQuestion($choiceQuestion)); } /** @@ -96,7 +105,6 @@ class DrupalStyle extends SymfonyStyle { $questionHelper = new DrupalChoiceQuestionHelper(); $answer = $questionHelper->ask($this->input, $this, $question); - return $answer; } @@ -107,21 +115,32 @@ class DrupalStyle extends SymfonyStyle */ public function askHiddenEmpty($question) { - $question = new Question($question, ' '); + $question = new Question($question, ''); $question->setHidden(true); + $question->setValidator( + function ($answer) { + return $answer; + } + ); return trim($this->askQuestion($question)); } /** - * @param string $question + * @param string $question + * @param string $default * @param null|callable $validator * * @return string */ - public function askEmpty($question, $validator = null) + public function askEmpty($question, $default = '', $validator = null) { - $question = new Question($question, ' '); + $question = new Question($question, $default); + if (!$validator) { + $validator = function ($answer) { + return $answer; + }; + } $question->setValidator($validator); return trim($this->askQuestion($question)); @@ -213,6 +232,14 @@ class DrupalStyle extends SymfonyStyle } } + /** + * {@inheritdoc} + */ + public function warning($message) + { + $this->block($message, 'WARNING', 'fg=white;bg=yellow', ' ', true); + } + /** * @param array|string $message */ @@ -271,4 +298,12 @@ class DrupalStyle extends SymfonyStyle parent::newLine(); } } + + /** + * @return InputInterface + */ + public function getInput() + { + return $this->input; + } }