/**
  * @param $body
  */
 public function basicPublish($body)
 {
     try {
         $this->getChannel()->basic_publish($this->message->setBody(json_encode($body)), '', $this->queue_name);
         $this->logger->info('Job published successfully!');
     } catch (\AMQPChannelException $e) {
         $this->logger->error($e->getMessage());
     }
 }
 /**
  * Execute `run` method with a default try & catch block to catch the exception.
  *
  * @param array $argv
  *
  * @return bool return true for success, false for failure. the returned
  *              state will be reflected to the exit code of the process.
  */
 public function runWithTry(array $argv)
 {
     try {
         return $this->run($argv);
     } catch (CommandArgumentNotEnoughException $e) {
         $this->logger->error($e->getMessage());
         $this->logger->writeln("Expected argument prototypes:");
         foreach ($e->getCommand()->getAllCommandPrototype() as $p) {
             $this->logger->writeln("\t" . $p);
         }
         $this->logger->newline();
     } catch (CommandNotFoundException $e) {
         $this->logger->error($e->getMessage() . " available commands are: " . join(', ', $e->getCommand()->getVisibleCommandList()));
         $this->logger->newline();
         $this->logger->writeln("Please try the command below to see the details:");
         $this->logger->newline();
         $this->logger->writeln("\t" . $this->getProgramName() . ' help ');
         $this->logger->newline();
     } catch (BadMethodCallException $e) {
         $this->logger->error($e->getMessage());
         $this->logger->error("Seems like an application logic error, please contact the developer.");
     } catch (Exception $e) {
         if ($this->options && $this->options->debug) {
             $printer = new DevelopmentExceptionPrinter($this->getLogger());
             $printer->dump($e);
         } else {
             $printer = new ProductionExceptionPrinter($this->getLogger());
             $printer->dump($e);
         }
     }
     return false;
 }
Exemple #3
0
 public function apply(Buildable $build, Logger $logger)
 {
     $patched = 0;
     foreach ($this->files as $file) {
         $path = $build->getSourceDirectory() . DIRECTORY_SEPARATOR . $file;
         if (!file_exists($path)) {
             $logger->error("file {$path} doesn't exist in the build directory.");
             continue;
         }
         if ($content = file_get_contents($path)) {
             $content = $this->applyTextContent($content, $patched);
             if (false === file_put_contents($path, $content)) {
                 $logger->error("Patch on {$path} write failed.");
             }
         }
     }
     return $patched;
 }