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 |
Output.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\Output;
013
014 use Symfony\Component\Console\Formatter\OutputFormatter;
015 use Symfony\Component\Console\Formatter\OutputFormatterInterface;
016
017 /**
018 * Base class for output classes.
019 *
020 * There are five levels of verbosity:
021 *
022 * * normal: no option passed (normal output)
023 * * verbose: -v (more output)
024 * * very verbose: -vv (highly extended output)
025 * * debug: -vvv (all debug output)
026 * * quiet: -q (no output)
027 *
028 * @author Fabien Potencier <fabien@symfony.com>
029 */
030 abstract class Output implements OutputInterface
031 {
032 private $verbosity;
033 private $formatter;
034
035 /**
036 * @param int $verbosity The verbosity level (one of the VERBOSITY constants in OutputInterface)
037 * @param bool $decorated Whether to decorate messages
038 * @param OutputFormatterInterface|null $formatter Output formatter instance (null to use default OutputFormatter)
039 */
040 public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = false, OutputFormatterInterface $formatter = null)
041 {
042 $this->verbosity = null === $verbosity ? self::VERBOSITY_NORMAL : $verbosity;
043 $this->formatter = $formatter ?: new OutputFormatter();
044 $this->formatter->setDecorated($decorated);
045 }
046
047 /**
048 * {@inheritdoc}
049 */
050 public function setFormatter(OutputFormatterInterface $formatter)
051 {
052 $this->formatter = $formatter;
053 }
054
055 /**
056 * {@inheritdoc}
057 */
058 public function getFormatter()
059 {
060 return $this->formatter;
061 }
062
063 /**
064 * {@inheritdoc}
065 */
066 public function setDecorated($decorated)
067 {
068 $this->formatter->setDecorated($decorated);
069 }
070
071 /**
072 * {@inheritdoc}
073 */
074 public function isDecorated()
075 {
076 return $this->formatter->isDecorated();
077 }
078
079 /**
080 * {@inheritdoc}
081 */
082 public function setVerbosity($level)
083 {
084 $this->verbosity = (int) $level;
085 }
086
087 /**
088 * {@inheritdoc}
089 */
090 public function getVerbosity()
091 {
092 return $this->verbosity;
093 }
094
095 /**
096 * {@inheritdoc}
097 */
098 public function isQuiet()
099 {
100 return self::VERBOSITY_QUIET === $this->verbosity;
101 }
102
103 /**
104 * {@inheritdoc}
105 */
106 public function isVerbose()
107 {
108 return self::VERBOSITY_VERBOSE <= $this->verbosity;
109 }
110
111 /**
112 * {@inheritdoc}
113 */
114 public function isVeryVerbose()
115 {
116 return self::VERBOSITY_VERY_VERBOSE <= $this->verbosity;
117 }
118
119 /**
120 * {@inheritdoc}
121 */
122 public function isDebug()
123 {
124 return self::VERBOSITY_DEBUG <= $this->verbosity;
125 }
126
127 /**
128 * {@inheritdoc}
129 */
130 public function writeln($messages, $options = self::OUTPUT_NORMAL)
131 {
132 $this->write($messages, true, $options);
133 }
134
135 /**
136 * {@inheritdoc}
137 */
138 public function write($messages, $newline = false, $options = self::OUTPUT_NORMAL)
139 {
140 $messages = (array) $messages;
141
142 $types = self::OUTPUT_NORMAL | self::OUTPUT_RAW | self::OUTPUT_PLAIN;
143 $type = $types & $options ?: self::OUTPUT_NORMAL;
144
145 $verbosities = self::VERBOSITY_QUIET | self::VERBOSITY_NORMAL | self::VERBOSITY_VERBOSE | self::VERBOSITY_VERY_VERBOSE | self::VERBOSITY_DEBUG;
146 $verbosity = $verbosities & $options ?: self::VERBOSITY_NORMAL;
147
148 if ($verbosity > $this->getVerbosity()) {
149 return;
150 }
151
152 foreach ($messages as $message) {
153 switch ($type) {
154 case OutputInterface::OUTPUT_NORMAL:
155 $message = $this->formatter->format($message);
156 break;
157 case OutputInterface::OUTPUT_RAW:
158 break;
159 case OutputInterface::OUTPUT_PLAIN:
160 $message = strip_tags($this->formatter->format($message));
161 break;
162 }
163
164 $this->doWrite($message, $newline);
165 }
166 }
167
168 /**
169 * Writes a message to the output.
170 *
171 * @param string $message A message to write to the output
172 * @param bool $newline Whether to add a newline or not
173 */
174 abstract protected function doWrite($message, $newline);
175 }
176