[Console] moved Output constants to OutputInterface

This commit is contained in:
Fabien Potencier 2011-03-29 21:53:28 +02:00
parent dbb18662d7
commit 49d67645d7
7 changed files with 18 additions and 10 deletions

View File

@ -65,6 +65,6 @@ EOF
$dumper = new ApacheMatcherDumper($router->getRouteCollection());
$output->writeln($dumper->dump($dumpOptions), Output::OUTPUT_RAW);
$output->writeln($dumper->dump($dumpOptions), OutputInterface::OUTPUT_RAW);
}
}

View File

@ -134,7 +134,7 @@ EOF
}
$output->writeln(sprintf('<comment>Options</comment> %s', $options));
$output->write('<comment>Regex</comment> ');
$output->writeln(preg_replace('/^ /', '', preg_replace('/^/m', ' ', $route->getRegex())), Output::OUTPUT_RAW);
$output->writeln(preg_replace('/^ /', '', preg_replace('/^/m', ' ', $route->getRegex())), OutputInterface::OUTPUT_RAW);
$tokens = '';
foreach ($route->getTokens() as $token) {

View File

@ -170,9 +170,9 @@ class Application
}
if (true === $input->hasParameterOption(array('--quiet', '-q'))) {
$output->setVerbosity(Output::VERBOSITY_QUIET);
$output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
} elseif (true === $input->hasParameterOption(array('--verbose', '-v'))) {
$output->setVerbosity(Output::VERBOSITY_VERBOSE);
$output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
}
if (true === $input->hasParameterOption(array('--version', '-V'))) {
@ -723,7 +723,7 @@ class Application
}
$output->writeln("\n");
if (Output::VERBOSITY_VERBOSE === $output->getVerbosity()) {
if (OutputInterface::VERBOSITY_VERBOSE === $output->getVerbosity()) {
$output->writeln('</comment>Exception trace:</comment>');
// exception related properties

View File

@ -74,7 +74,7 @@ EOF
}
if ($input->getOption('xml')) {
$output->writeln($this->command->asXml(), Output::OUTPUT_RAW);
$output->writeln($this->command->asXml(), OutputInterface::OUTPUT_RAW);
} else {
$output->writeln($this->command->asText());
}

View File

@ -59,7 +59,7 @@ EOF
protected function execute(InputInterface $input, OutputInterface $output)
{
if ($input->getOption('xml')) {
$output->writeln($this->getApplication()->asXml($input->getArgument('namespace')), Output::OUTPUT_RAW);
$output->writeln($this->getApplication()->asXml($input->getArgument('namespace')), OutputInterface::OUTPUT_RAW);
} else {
$output->writeln($this->getApplication()->asText($input->getArgument('namespace')));
}

View File

@ -168,12 +168,12 @@ abstract class Output implements OutputInterface
foreach ($messages as $message) {
switch ($type) {
case Output::OUTPUT_NORMAL:
case OutputInterface::OUTPUT_NORMAL:
$message = $this->formatter->format($message);
break;
case Output::OUTPUT_RAW:
case OutputInterface::OUTPUT_RAW:
break;
case Output::OUTPUT_PLAIN:
case OutputInterface::OUTPUT_PLAIN:
$message = strip_tags($this->formatter->format($message));
break;
default:

View File

@ -22,6 +22,14 @@ use Symfony\Component\Console\Formatter\OutputFormatterInterface;
*/
interface OutputInterface
{
const VERBOSITY_QUIET = 0;
const VERBOSITY_NORMAL = 1;
const VERBOSITY_VERBOSE = 2;
const OUTPUT_NORMAL = 0;
const OUTPUT_RAW = 1;
const OUTPUT_PLAIN = 2;
/**
* Writes a message to the output.
*