[ Index ] |
PHP Cross Reference of phpBB-3.1.12-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 3 /* 4 * This file is part of the Symfony package. 5 * 6 * (c) Fabien Potencier <fabien@symfony.com> 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12 namespace Symfony\Component\Console\Output; 13 14 use Symfony\Component\Console\Formatter\OutputFormatterInterface; 15 use Symfony\Component\Console\Formatter\OutputFormatter; 16 17 /** 18 * Base class for output classes. 19 * 20 * There are five levels of verbosity: 21 * 22 * * normal: no option passed (normal output) 23 * * verbose: -v (more output) 24 * * very verbose: -vv (highly extended output) 25 * * debug: -vvv (all debug output) 26 * * quiet: -q (no output) 27 * 28 * @author Fabien Potencier <fabien@symfony.com> 29 */ 30 abstract class Output implements OutputInterface 31 { 32 private $verbosity; 33 private $formatter; 34 35 /** 36 * Constructor. 37 * 38 * @param int $verbosity The verbosity level (one of the VERBOSITY constants in OutputInterface) 39 * @param bool $decorated Whether to decorate messages 40 * @param OutputFormatterInterface|null $formatter Output formatter instance (null to use default OutputFormatter) 41 */ 42 public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = false, OutputFormatterInterface $formatter = null) 43 { 44 $this->verbosity = null === $verbosity ? self::VERBOSITY_NORMAL : $verbosity; 45 $this->formatter = null === $formatter ? new OutputFormatter() : $formatter; 46 $this->formatter->setDecorated($decorated); 47 } 48 49 /** 50 * {@inheritdoc} 51 */ 52 public function setFormatter(OutputFormatterInterface $formatter) 53 { 54 $this->formatter = $formatter; 55 } 56 57 /** 58 * {@inheritdoc} 59 */ 60 public function getFormatter() 61 { 62 return $this->formatter; 63 } 64 65 /** 66 * {@inheritdoc} 67 */ 68 public function setDecorated($decorated) 69 { 70 $this->formatter->setDecorated($decorated); 71 } 72 73 /** 74 * {@inheritdoc} 75 */ 76 public function isDecorated() 77 { 78 return $this->formatter->isDecorated(); 79 } 80 81 /** 82 * {@inheritdoc} 83 */ 84 public function setVerbosity($level) 85 { 86 $this->verbosity = (int) $level; 87 } 88 89 /** 90 * {@inheritdoc} 91 */ 92 public function getVerbosity() 93 { 94 return $this->verbosity; 95 } 96 97 /** 98 * {@inheritdoc} 99 */ 100 public function writeln($messages, $type = self::OUTPUT_NORMAL) 101 { 102 $this->write($messages, true, $type); 103 } 104 105 /** 106 * {@inheritdoc} 107 */ 108 public function write($messages, $newline = false, $type = self::OUTPUT_NORMAL) 109 { 110 if (self::VERBOSITY_QUIET === $this->verbosity) { 111 return; 112 } 113 114 $messages = (array) $messages; 115 116 foreach ($messages as $message) { 117 switch ($type) { 118 case OutputInterface::OUTPUT_NORMAL: 119 $message = $this->formatter->format($message); 120 break; 121 case OutputInterface::OUTPUT_RAW: 122 break; 123 case OutputInterface::OUTPUT_PLAIN: 124 $message = strip_tags($this->formatter->format($message)); 125 break; 126 default: 127 throw new \InvalidArgumentException(sprintf('Unknown output type given (%s)', $type)); 128 } 129 130 $this->doWrite($message, $newline); 131 } 132 } 133 134 /** 135 * Writes a message to the output. 136 * 137 * @param string $message A message to write to the output 138 * @param bool $newline Whether to add a newline or not 139 */ 140 abstract protected function doWrite($message, $newline); 141 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Jan 11 00:25:41 2018 | Cross-referenced by PHPXref 0.7.1 |