/**
  * {@inheritdoc}
  */
 protected function handle(JobInterface $job)
 {
     try {
         parent::handle($job);
         $this->container->get('cqrs.command_bus')->dispatchNow($job);
     } catch (\Exception $e) {
         $this->output->writeln(sprintf('<style name="error">%s</style>', $e->getMessage()));
     }
 }
 /**
  * Execute console.
  *
  * @param AbstractInput $input
  * @param Output        $output
  */
 protected function execute(AbstractInput $input, Output $output)
 {
     $output->writeln($this->getApplication()->getApplicationVersion());
     $output->write("\n");
     $names = $this->getConsoles();
     $width = $output->getMaxWidth($names) + 4;
     $output->writeln(sprintf('<style name="comment">%s</style>', 'Available commands:'));
     foreach ($names as $name) {
         $description = null;
         $cleanName = strip_tags(trim($name));
         if ($this->application->hasConsole($cleanName)) {
             $description = $this->application->getConsole($cleanName)->getDescription();
         }
         $output->writeln($output->width($width, $name) . '  ' . (string) $description);
     }
 }
Ejemplo n.º 3
0
 /**
  * Write border.
  *
  * @param int[] $widths
  */
 private function writeBorders(array $widths)
 {
     foreach ($widths as $width) {
         $this->output->write('+');
         $this->output->write(str_repeat('-', $width));
     }
     $this->output->writeln('+');
 }
 /**
  * Execute console.
  *
  * @param AbstractInput $input
  * @param Output        $output
  */
 protected function execute(AbstractInput $input, Output $output)
 {
     $address = $input->option->get('address');
     $port = $input->option->get('port');
     $processControl = new ProcessControl(sprintf('%s:%s', $address, $port));
     if (false === $processControl->isRunning()) {
         throw new RuntimeException(sprintf('There are no active daemon run in "%s:%s"', $address, $port));
     }
     $output->writeln('<style name="info">Shutting down Borobudur development server</style>');
     $processControl->kill();
 }
 /**
  * Execute console.
  *
  * @param AbstractInput $input
  * @param Output        $output
  */
 protected function execute(AbstractInput $input, Output $output)
 {
     $class = $input->argument->get($this->getMessageType());
     $this->reflection = new ReflectionClass($this->parseClass($class));
     /** @var MessageInterface $message */
     $message = $this->createMessage((array) json_decode($input->argument->get('data'), true));
     $result = $this->getBus()->dispatch($message);
     if (true === $input->option->get('serialize')) {
         if (method_exists($result, 'serialize')) {
             $result = $result->serialize();
         } elseif (method_exists($result, 'toArray')) {
             $result = $result->toArray();
         }
     }
     $output->writeln(sprintf('<style name="info">Dump result: </style>'));
     var_dump($result);
 }
 /**
  * Write list of options.
  *
  * @param array           $options
  * @param int             $width
  * @param AbstractConsole $console
  * @param Output          $output
  */
 private function writeOptions(array $options, $width, AbstractConsole $console, Output $output)
 {
     if (!empty($options)) {
         $output->writeln();
         $output->writeln(sprintf('<style name="comment">%s</style>', 'Options:'));
         foreach ($options as $option) {
             $clean = trim(strip_tags($option));
             $pos = strpos($clean, '--');
             $parts = explode('=', substr($clean, $pos + 2));
             $opt = $console->getDefinition()->getOption($parts[0]);
             $description = $opt->getDescription();
             if (null !== ($default = $opt->getDefault())) {
                 if ($description) {
                     $description .= ' ';
                 }
                 $description .= sprintf('<style name="comment">[default: "%s"]</style>', $default);
             }
             $output->writeln($output->width($width, $option) . '  ' . $description);
         }
     }
 }
 /**
  * Write exception.
  *
  * @param Exception $e
  * @param Output    $output
  */
 protected function writeException(Exception $e, Output $output)
 {
     $class = get_class($e);
     $pos = strrpos($class, '\\');
     $title = sprintf('  [%s]  ', false === $pos ? $class : substr($class, $pos + 1));
     $msg = '  ' . $e->getMessage();
     $max = (strlen($title) > strlen($msg) ? strlen($title) : strlen($msg)) + 2;
     $messages = array();
     $messages[] = $title;
     $messages[] = $msg;
     $output->writeln(sprintf('<style name="error">%s</style>', str_repeat(' ', $max)));
     foreach ($messages as $msg) {
         $output->write(sprintf('<style name="error">%s</style>', $msg));
         $output->write(sprintf('<style name="error">%s</style>', str_repeat(' ', $max - strlen($msg))));
         $output->writeln('');
     }
     $output->writeln(sprintf('<style name="error">%s</style>', str_repeat(' ', $max)));
 }
 /**
  * Event listener when queue halted.
  */
 public function halted()
 {
     $this->output->writeln('Queue worker stopped');
 }
 /**
  * Execute console.
  *
  * @param AbstractInput $input
  * @param Output        $output
  */
 protected function execute(AbstractInput $input, Output $output)
 {
     $output->writeln($this->application->getApplicationVersion());
 }
 private function sayGreeting()
 {
     $this->output->writeln(sprintf('<style name="info">%s</style>', sprintf('Borobudur development server started on http://%s:%s', $this->address, $this->port)));
 }