Exemple #1
0
 public function testJsonEncode_EncodesData()
 {
     $testData = 'something something 123';
     $testType = 'testType';
     $expected = json_encode(['type' => $testType, 'data' => $testData]);
     $this->abstractCommand->expects($this->once())->method('getType')->willReturn('testType');
     $this->abstractCommand->setData($testData);
     $this->assertJsonStringEqualsJsonString($expected, json_encode($this->abstractCommand));
 }
 /**
  * Validate configuration
  *
  * @return boolean
  */
 protected function validateConfiguration()
 {
     $ret = parent::validateConfiguration();
     // Rsync required for share
     $ret = $ret && $this->validateConfigurationRsync();
     return $ret;
 }
 /**
  * Add an argument(sub command) setting. This method in Command use 'self' instead 'static' to make sure every sub
  * command add Command class as arguments.
  *
  * @param   string|AbstractCommand  $command      The argument name or Console object.
  *                                                If we just send a string, the object will auto create.
  * @param   null                    $description  Console description.
  * @param   array                   $options      Console options.
  * @param   \Closure                $code         The closure to execute.
  *
  * @return  AbstractCommand  Return this object to support chaining.
  *
  * @since   2.0
  */
 public function addCommand($command, $description = null, $options = array(), \Closure $code = null)
 {
     if (!$command instanceof AbstractCommand) {
         $command = new self($command, $this->io, $this);
     }
     return parent::addCommand($command, $description, $options, $code);
 }
 /**
  * Add an argument(sub command) setting. This method in Command use 'self' instead 'static' to make sure every sub
  * command add Command class as arguments.
  *
  * @param   string|AbstractCommand  $command      The argument name or Console object.
  *                                                If we just send a string, the object will auto create.
  * @param   null                    $description  Console description.
  * @param   array                   $options      Console options.
  * @param   \Closure                $code         The closure to execute.
  *
  * @return  AbstractCommand  Return this object to support chaining.
  *
  * @since   2.0
  */
 public function addCommand($command, $description = null, $options = array(), \Closure $code = null)
 {
     if (is_string($command) && class_exists($command) && is_subclass_of($command, __CLASS__)) {
         $command = new $command();
     }
     if (!$command instanceof AbstractCommand) {
         $command = new self($command, $this->io, $this);
     }
     return parent::addCommand($command, $description, $options, $code);
 }
 /**
  * Validate configuration
  *
  * @return boolean
  */
 protected function validateConfiguration()
 {
     $ret = parent::validateConfiguration();
     $output = $this->output;
     // ##################
     // SSH (optional)
     // ##################
     if ($this->config->exists('ssh')) {
         // Check if one database is configured
         if (!$this->config->exists('ssh.hostname')) {
             $output->writeln('<p-error>No ssh hostname configuration found</p-error>');
             $ret = false;
         }
     }
     return $ret;
 }
 /**
  * @see \Sdc\AppBundle\Command\Command::execute()
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     parent::execute($input, $output);
     $start = new \DateTime();
     $this->writeLn(sprintf(" Start at %s", $start->format('Y-m-d H:i:s')));
     $this->initGeneratorOptions();
     if ($this->canExecute() === true) {
         $this->initGenerator()->getGenerator()->generatePackage();
     } elseif ($this->canExecute() === false) {
         $this->writeLn("  Generation not launched, use \"--force\" option to force generation");
         $this->writeLn(sprintf("  Generator's option file used: %s", $this->resolveGeneratorOptionsConfigPath()));
         $this->writeLn("  Used generator's options:");
         $this->writeLn("    " . implode(PHP_EOL . '    ', $this->formatArrayForConsole($this->generatorOptions->toArray())));
     }
     $end = new \DateTime();
     $this->writeLn(sprintf(" End at %s, duration: %s", $end->format('Y-m-d H:i:s'), $start->diff($end)->format('%H:%I:%S')));
 }
 public function __construct()
 {
     parent::__construct();
 }
 protected function configure()
 {
     parent::configure();
     $this->setName('madrakio:persistentcommand:stop')->setDescription("Updates all running processes on this node to the stop status.");
 }
Exemple #9
0
 /**
  * Write a string to standard output.
  *
  * @param   string   $text  The text to display.
  * @param   boolean  $nl    True (default) to append a new line at the end of the output string.
  *
  * @return  Command  Instance of $this to allow chaining.
  *
  * @since   1.0
  */
 public function out($text = '', $nl = true)
 {
     if (!$this->getOption('q', 0)) {
         parent::out($text, $nl);
     }
     return $this;
 }