Example #1
0
 /**
  * Export current report as follows:
  *
  * 1. Display messages on CLI
  * 2. Run all formatters and display their text results on CLI
  *
  * If no formatter has been specified a default writer will be used depending
  * on the file extension given. Without a file extension a plain text writer
  * will be used.
  */
 public function run()
 {
     $output = $this->command->getOutput();
     $output->writeln('');
     $output->writeln('---------------------');
     $output->writeln('-- Report follows: --');
     $output->writeln('---------------------');
     $output->writeln('');
     $formatter = new ConsoleMessageFormatter();
     $console_report_text = $formatter->format($this->report);
     $output->writeln($console_report_text);
     $output->writeln('');
     $output->writeln('---------------------');
     $output->writeln('-- Export follows: --');
     $output->writeln('---------------------');
     $output->writeln('');
     $default_formatter = array('location' => self::DEFAULT_EXPORT_LOCATION);
     $formatter_definitions = $this->parameters->get('formatters', array($default_formatter));
     foreach ($formatter_definitions as $formatter_definition) {
         $params = new Parameters($formatter_definition);
         $location = $params->get('location', self::DEFAULT_EXPORT_LOCATION);
         if ($params->has('__class')) {
             $formatter_class = $params->get('__class');
         } else {
             $formatter_class = $this->getFormatterByExtension($location);
         }
         $formatter = new $formatter_class();
         $formatter->setParameters($params);
         $output->writeln('Starting export via "' . $formatter_class . '".');
         $export_text = $formatter->format($this->report);
         $output->writeln($export_text);
     }
     $output->writeln('');
 }
Example #2
0
 /**
  * @return \Symfony\Component\Console\Output\OutputInterface
  */
 public function getOutputStream()
 {
     return $this->command->getOutput();
 }