Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
SymfonyQuestionHelper.php
001 <?php
002
003 /*
004 * This file is part of the Symfony package.
005 *
006 * (c) Fabien Potencier <fabien@symfony.com>
007 *
008 * For the full copyright and license information, please view the LICENSE
009 * file that was distributed with this source code.
010 */
011
012 namespace Symfony\Component\Console\Helper;
013
014 use Symfony\Component\Console\Exception\LogicException;
015 use Symfony\Component\Console\Formatter\OutputFormatter;
016 use Symfony\Component\Console\Input\InputInterface;
017 use Symfony\Component\Console\Output\OutputInterface;
018 use Symfony\Component\Console\Question\ChoiceQuestion;
019 use Symfony\Component\Console\Question\ConfirmationQuestion;
020 use Symfony\Component\Console\Question\Question;
021 use Symfony\Component\Console\Style\SymfonyStyle;
022
023 /**
024 * Symfony Style Guide compliant question helper.
025 *
026 * @author Kevin Bond <kevinbond@gmail.com>
027 */
028 class SymfonyQuestionHelper extends QuestionHelper
029 {
030 /**
031 * {@inheritdoc}
032 *
033 * To be removed in 4.0
034 */
035 public function ask(InputInterface $input, OutputInterface $output, Question $question)
036 {
037 $validator = $question->getValidator();
038 $question->setValidator(function ($value) use ($validator) {
039 if (null !== $validator) {
040 $value = $validator($value);
041 } else {
042 // make required
043 if (!\is_array($value) && !\is_bool($value) && 0 === \strlen($value)) {
044 @trigger_error('The default question validator is deprecated since Symfony 3.3 and will not be used anymore in version 4.0. Set a custom question validator if needed.', \E_USER_DEPRECATED);
045
046 throw new LogicException('A value is required.');
047 }
048 }
049
050 return $value;
051 });
052
053 return parent::ask($input, $output, $question);
054 }
055
056 /**
057 * {@inheritdoc}
058 */
059 protected function writePrompt(OutputInterface $output, Question $question)
060 {
061 $text = OutputFormatter::escapeTrailingBackslash($question->getQuestion());
062 $default = $question->getDefault();
063
064 switch (true) {
065 case null === $default:
066 $text = sprintf(' <info>%s</info>:', $text);
067
068 break;
069
070 case $question instanceof ConfirmationQuestion:
071 $text = sprintf(' <info>%s (yes/no)</info> [<comment>%s</comment>]:', $text, $default ? 'yes' : 'no');
072
073 break;
074
075 case $question instanceof ChoiceQuestion && $question->isMultiselect():
076 $choices = $question->getChoices();
077 $default = explode(',', $default);
078
079 foreach ($default as $key => $value) {
080 $default[$key] = $choices[trim($value)];
081 }
082
083 $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape(implode(', ', $default)));
084
085 break;
086
087 case $question instanceof ChoiceQuestion:
088 $choices = $question->getChoices();
089 $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape(isset($choices[$default]) ? $choices[$default] : $default));
090
091 break;
092
093 default:
094 $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape($default));
095 }
096
097 $output->writeln($text);
098
099 $prompt = ' > ';
100
101 if ($question instanceof ChoiceQuestion) {
102 $output->writeln($this->formatChoiceQuestionChoices($question, 'comment'));
103
104 $prompt = $question->getPrompt();
105 }
106
107 $output->write($prompt);
108 }
109
110 /**
111 * {@inheritdoc}
112 */
113 protected function writeError(OutputInterface $output, \Exception $error)
114 {
115 if ($output instanceof SymfonyStyle) {
116 $output->newLine();
117 $output->error($error->getMessage());
118
119 return;
120 }
121
122 parent::writeError($output, $error);
123 }
124 }
125