當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Command::run方法代碼示例

本文整理匯總了PHP中Symfony\Component\Console\Command\Command::run方法的典型用法代碼示例。如果您正苦於以下問題:PHP Command::run方法的具體用法?PHP Command::run怎麽用?PHP Command::run使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\Console\Command\Command的用法示例。


在下文中一共展示了Command::run方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: check

 /**
  * Perform the actual check and return a ResultInterface
  *
  * @return ResultInterface
  * @throws \Exception
  */
 public function check()
 {
     $exitCode = $this->command->run($this->input, $this->output);
     $data = [];
     if ($this->output instanceof PropertyOutput) {
         $data = $this->output->getMessage();
         if (!is_array($data)) {
             $data = explode(PHP_EOL, trim($data));
         }
     }
     if ($exitCode < 1) {
         return new Success(get_class($this->command), $data);
     }
     return new Failure(get_class($this->command), $data);
 }
開發者ID:abacaphiliac,項目名稱:doctrine-orm-diagnostics-module,代碼行數:21,代碼來源:CheckCommand.php

示例2: run

 public function run(InputInterface $input, OutputInterface $output)
 {
     // Store the input and output for easier usage
     $this->input = $input;
     $this->output = $output;
     parent::run($input, $output);
 }
開發者ID:bonndan,項目名稱:release-manager,代碼行數:7,代碼來源:BaseCommand.php

示例3: execute

 /**
  * Execute this console command
  *
  * @param  InputInterface  $input  Command line input interface
  * @param  OutputInterface $output Command line output interface
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $dropTables = $input->getOption('drop-tables');
     if (!$this->hasTablesOrViews() || $dropTables) {
         if ($dropTables && $this->appEnv === 'production') {
             $output->writeln('Cannot drop tables when app environment is production.');
             return;
         }
         // Console message heading padded by a newline
         $output->write(['', '  -- APP INSTALL --', ''], true);
         $output->write(['  Dropping tables', ''], true);
         $this->dropViews();
         $this->dropTables();
         try {
             $installScript = $this->getInstallScript();
         } catch (RuntimeException $e) {
             $output->writeln($e->getMessage());
             return;
         }
         $this->install($installScript, $output);
     }
     // Run all migrations
     $output->writeln('  Executing new migrations');
     $this->runMigrationsCommand->run(new ArrayInput(['migrations:run']), $output);
     $output->write(['  Done!', ''], true);
 }
開發者ID:bodetree,項目名稱:synapse-base,代碼行數:32,代碼來源:RunInstallCommand.php

示例4: runCommand

 /**
  * Run given command and return its output.
  *
  * @param Command $command
  * @param array $input
  * @return string
  */
 protected function runCommand(Command $command, array $input = [])
 {
     $stream = fopen("php://memory", "r+");
     $input = new ArrayInput($input);
     $command->run($input, new StreamOutput($stream));
     rewind($stream);
     return stream_get_contents($stream);
 }
開發者ID:bound1ess,項目名稱:adviser,代碼行數:15,代碼來源:CommandTestCase.php

示例5: executeCommand

 private function executeCommand(Command $command, Input $input)
 {
     $command->setApplication($this->application);
     $input->setInteractive(false);
     if ($command instanceof ContainerAwareCommand) {
         $command->setContainer($this->client->getContainer());
     }
     $command->run($input, new NullOutput());
 }
開發者ID:ajouve,項目名稱:doctrine-fixtures-test,代碼行數:9,代碼來源:FixtureTestCase.php

示例6: run

 public function run(InputInterface $input, OutputInterface $output)
 {
     try {
         return parent::run($input, $output);
     } catch (\Exception $e) {
         if ($input->getOption('alert')) {
             mtrace($e, "Exception while running command " . $this->getName(), 'alert');
         }
         throw $e;
     }
 }
開發者ID:oasmobile,項目名稱:php-slimapp,代碼行數:11,代碼來源:AbstractAlertableCommand.php

示例7: run

 /**
  * Override run to let Exceptions function as exit codes.
  */
 public function run(InputInterface $input, OutputInterface $output)
 {
     $this->input = $input;
     $this->output = $output;
     try {
         return parent::run($input, $output);
     } catch (Exception $e) {
         $output->writeln("<error>" . $e->getMessage() . "</error>");
         return $e->getCode() > 0 ? $e->getCode() : 1;
     }
 }
開發者ID:xendk,項目名稱:proctor,代碼行數:14,代碼來源:ProctorCommand.php

示例8: executeCommand

 protected static function executeCommand(Command $command, $siteDir)
 {
     if (!is_dir($siteDir)) {
         throw new \RuntimeException('The meinhof-site-dir (' . $siteDir . ') specified in composer.json was not found in ' . getcwd());
     }
     $helpers = new HelperSet(array(new FormatterHelper(), new DialogHelper()));
     $command->setHelperSet($helpers);
     $input = new ArrayInput(array('dir' => $siteDir));
     $output = new ConsoleOutput();
     $command->run($input, $output);
 }
開發者ID:miguelibero,項目名稱:meinhof,代碼行數:11,代碼來源:ScriptHandler.php

示例9: run

 public function run(InputInterface $input, OutputInterface $output)
 {
     $this->depedencies = $this->getApplication()->getKernel()->getContainer()->get('mardraze_core.depedencies');
     $context = $this->depedencies->get('router')->getContext();
     $mainHost = $this->depedencies->getParameter('mardraze_http_host');
     $host = preg_replace('/http(s)?:\\/\\//', '', $mainHost);
     $scheme = strpos($mainHost, 'https:') === false ? 'http' : 'https';
     $context->setHost($host);
     $context->setScheme($scheme);
     $this->input = $input;
     $this->output = $output;
     return parent::run($input, $output);
 }
開發者ID:mardraze,項目名稱:core-bundle,代碼行數:13,代碼來源:MardrazeBaseCommand.php

示例10: run

 /**
  * {@inheritdoc}
  */
 public function run(InputInterface $input, OutputInterface $output)
 {
     // Store the input and output for easier usage
     $this->input = $input;
     if (!$output instanceof Output) {
         throw new \InvalidArgumentException('Not the expected output type');
     }
     $this->output = $output;
     $dialogHelper = class_exists('Symfony\\Component\\Console\\Helper\\QuestionHelper') ? $this->getHelperSet()->get('question') : $this->getHelperSet()->get('dialog');
     $this->output->setDialogHelper($dialogHelper);
     $this->output->setFormatterHelper($this->getHelperSet()->get('formatter'));
     Context::getInstance()->setService('input', $this->input);
     Context::getInstance()->setService('output', $this->output);
     parent::run($input, $output);
 }
開發者ID:liip,項目名稱:rmt,代碼行數:18,代碼來源:BaseCommand.php

示例11: run

 /**
  * Runs the command.
  *
  * Before the decorated command is run, a lock is requested.
  * When failed to acquire the lock, the command exits.
  *
  * @param InputInterface  $input  An InputInterface instance
  * @param OutputInterface $output An OutputInterface instance
  *
  * @return int The command exit code
  */
 public function run(InputInterface $input, OutputInterface $output)
 {
     $this->mergeApplicationDefinition();
     $input->bind($this->getDefinition());
     $lock = $this->getLockHandler($input);
     if (!$lock->lock()) {
         $this->writeLockedMessage($input, $output);
         return 1;
     }
     try {
         return $this->decoratedCommand->run($input, $output);
     } finally {
         $lock->release();
     }
 }
開發者ID:frankdejonge,項目名稱:locked-console-command,代碼行數:26,代碼來源:LockedCommandDecorator.php

示例12: run

    public function run(InputInterface $input, OutputInterface $output)
    {
        try {
            return parent::run($input, $output);
        } catch (RuntimeException $e) {
            if ($e->getMessage() === 'invalid token') {
                throw new AuthException(<<<TEXT
Your authentication token is invalid or has not been set yet.
Execute 'trello config generate' and follow the instructions.
TEXT
);
            } else {
                throw $e;
            }
        }
    }
開發者ID:svenax,項目名稱:trello-cli,代碼行數:16,代碼來源:CommandBase.php

示例13: run

 /**
  * @see Symfony\Component\Console\Command\Command::run()
  */
 public function run(InputInterface $input, OutputInterface $output)
 {
     // Force the creation of the synopsis before the merge with the app definition
     $this->getSynopsis();
     // Merge our options
     $this->addOption('run-once', null, InputOption::VALUE_NONE, 'Run the command just once, do not go into an endless loop');
     $this->addOption('detect-leaks', null, InputOption::VALUE_NONE, 'Output information about memory usage');
     // Add the signal handler
     if (function_exists('pcntl_signal')) {
         // Enable ticks for fast signal processing
         declare (ticks=1);
         pcntl_signal(SIGTERM, array($this, 'handleSignal'));
         pcntl_signal(SIGINT, array($this, 'handleSignal'));
     }
     // And now run the command
     return parent::run($input, $output);
 }
開發者ID:famouscake,項目名稱:daemonizable-command,代碼行數:20,代碼來源:EndlessCommand.php

示例14: execute

 public function execute(Command $command, array $input, array $options = array())
 {
     // set the command name automatically if the application requires
     // this argument and no command name was passed
     if (!isset($input['command']) && null !== ($application = $this->command->getApplication()) && $application->getDefinition()->hasArgument('command')) {
         $input = array_merge(array('command' => $this->command->getName()), $input);
     }
     $this->input = new ArrayInput($input);
     if (isset($options['interactive'])) {
         $this->input->setInteractive($options['interactive']);
     }
     $this->output = new StreamOutput(fopen('php://memory', 'w', false));
     if (isset($options['decorated'])) {
         $this->output->setDecorated($options['decorated']);
     }
     if (isset($options['verbosity'])) {
         $this->output->setVerbosity($options['verbosity']);
     }
     return $this->statusCode = $command->run($this->input, $this->output);
 }
開發者ID:kodazzi,項目名稱:framework,代碼行數:20,代碼來源:Shell.php

示例15: run

 public function run(InputInterface $input, OutputInterface $output)
 {
     // check if the php pcntl_signal functions are accessible
     $this->php_pcntl_signal = function_exists('pcntl_signal');
     if ($this->php_pcntl_signal) {
         // Collect interrupts and notify the running command
         pcntl_signal(SIGTERM, [$this, 'cancelOperation']);
         pcntl_signal(SIGINT, [$this, 'cancelOperation']);
     }
     return parent::run($input, $output);
 }
開發者ID:ZverAleksey,項目名稱:core,代碼行數:11,代碼來源:base.php


注:本文中的Symfony\Component\Console\Command\Command::run方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。