本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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());
}
示例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;
}
}
示例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;
}
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
}
示例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;
}
}
}
示例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);
}
示例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);
}
示例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);
}