From 49d67645d7b9b1c8e8c26ba6fa8c6e089e31c0b9 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 29 Mar 2011 21:53:28 +0200 Subject: [PATCH] [Console] moved Output constants to OutputInterface --- .../FrameworkBundle/Command/RouterApacheDumperCommand.php | 2 +- .../Bundle/FrameworkBundle/Command/RouterDebugCommand.php | 2 +- src/Symfony/Component/Console/Application.php | 6 +++--- src/Symfony/Component/Console/Command/HelpCommand.php | 2 +- src/Symfony/Component/Console/Command/ListCommand.php | 2 +- src/Symfony/Component/Console/Output/Output.php | 6 +++--- src/Symfony/Component/Console/Output/OutputInterface.php | 8 ++++++++ 7 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/RouterApacheDumperCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/RouterApacheDumperCommand.php index 9e14cf08c2..7a99fd5550 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/RouterApacheDumperCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/RouterApacheDumperCommand.php @@ -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); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php index 04a0f4a461..e5d18d5bce 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php @@ -134,7 +134,7 @@ EOF } $output->writeln(sprintf('Options %s', $options)); $output->write('Regex '); - $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) { diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index e11eb96b2b..9e88575a54 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -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('Exception trace:'); // exception related properties diff --git a/src/Symfony/Component/Console/Command/HelpCommand.php b/src/Symfony/Component/Console/Command/HelpCommand.php index bf5d238772..85c46cea52 100644 --- a/src/Symfony/Component/Console/Command/HelpCommand.php +++ b/src/Symfony/Component/Console/Command/HelpCommand.php @@ -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()); } diff --git a/src/Symfony/Component/Console/Command/ListCommand.php b/src/Symfony/Component/Console/Command/ListCommand.php index 67f7e26cd3..f5300e13d2 100644 --- a/src/Symfony/Component/Console/Command/ListCommand.php +++ b/src/Symfony/Component/Console/Command/ListCommand.php @@ -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'))); } diff --git a/src/Symfony/Component/Console/Output/Output.php b/src/Symfony/Component/Console/Output/Output.php index 1f39c9caf7..e791ce6b26 100644 --- a/src/Symfony/Component/Console/Output/Output.php +++ b/src/Symfony/Component/Console/Output/Output.php @@ -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: diff --git a/src/Symfony/Component/Console/Output/OutputInterface.php b/src/Symfony/Component/Console/Output/OutputInterface.php index 012a5093ac..24e71da65d 100644 --- a/src/Symfony/Component/Console/Output/OutputInterface.php +++ b/src/Symfony/Component/Console/Output/OutputInterface.php @@ -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. *