当前位置: 首页>>代码示例>>PHP>>正文


PHP ContainerAwareCommand::run方法代码示例

本文整理汇总了PHP中Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand::run方法的典型用法代码示例。如果您正苦于以下问题:PHP ContainerAwareCommand::run方法的具体用法?PHP ContainerAwareCommand::run怎么用?PHP ContainerAwareCommand::run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand的用法示例。


在下文中一共展示了ContainerAwareCommand::run方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 /**
  * {@inheritdoc}
  *
  * @throws \RuntimeException When another task is already running.
  */
 public function run(InputInterface $input, OutputInterface $output)
 {
     // If successfully forked, exit now as the parenting process is done.
     if ($this->fork()) {
         $output->writeln('Forked into background.');
         return 0;
     }
     return parent::run($input, $output);
 }
开发者ID:tenside,项目名称:core-bundle,代码行数:14,代码来源:RunTaskCommand.php

示例2: run

 public function run(InputInterface $inputInterface, OutputInterface $outputInterface)
 {
     register_shutdown_function(array($this, 'terminate'), $inputInterface, $outputInterface);
     \Amp\run(function () use($inputInterface, $outputInterface) {
         \Amp\repeat(function () use($inputInterface, $outputInterface) {
             if ($leaking = $this->isLeaking()) {
                 $this->getContainer()->get('logger')->alert('Memory leaked.', $leaking);
             }
             parent::run($inputInterface, $outputInterface);
         }, 1);
         $outputInterface->writeln('The command has <info>successfully</info> started.');
     });
 }
开发者ID:skedone,项目名称:DaemonsBundle,代码行数:13,代码来源:ContainerAwareDaemonCommand.php

示例3: run

 public function run(InputInterface $input, OutputInterface $output)
 {
     $start = new \DateTime();
     $output->writeln('<comment>' . $this->getName() . '</comment> started at <info>' . $start->format('Y-m-d H:i:s') . '</info>');
     $msg = '';
     try {
         $return = parent::run($input, $output);
     } catch (\Exception $ex) {
         $msg = '<error>FAILURE of </error>';
         $this->onError($input, $output, $ex);
     }
     $end = new \DateTime();
     $duration = Carbon::instance($start)->diffInSeconds(Carbon::instance($end));
     $msg .= '<comment>' . $this->getName() . '</comment> ended at <info>' . $end->format('Y-m-d H:i:s') . '</info>. Duration is <info>' . $duration . '</info> seconds.';
     $this->displayMemory($output);
     $output->writeln($msg);
     if (isset($ex)) {
         $this->dispatch(CommandEvents::ERROR, new CommandEvent($this, array('exception' => $ex)));
         throw $ex;
     }
     $this->dispatch(CommandEvents::TERMINATE, new CommandEvent($this));
     return $return;
 }
开发者ID:fvilpoix,项目名称:php-common,代码行数:23,代码来源:AbstractCommand.php

示例4: run

 /**
  * @param InputInterface $inputInterface
  * @param OutputInterface $outputInterface
  * @return int|void
  * @throws \Keboola\ProvisioningBundle\Provisioning\Exception
  */
 public function run(InputInterface $inputInterface, OutputInterface $outputInterface)
 {
     if ($this->getContainer()->hasParameter("maintenance.status") && $this->getContainer()->getParameter("maintenance.status") == true) {
         throw new Exception("Maintenance");
     }
     return parent::run($inputInterface, $outputInterface);
 }
开发者ID:keboola,项目名称:provisioning-bundle,代码行数:13,代码来源:Command.php

示例5: run

 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return int
  *
  * @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();
     // 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:Grosloup,项目名称:DaemonBundle,代码行数:22,代码来源:DaemonCommand.php

示例6: run

 /**
  * Override framework function to add pre and post hooks around the parent functionality
  *
  * @param InputInterface  $input An InputInterface instance
  * @param OutputInterface $output An OutputInterface instance
  *
  * @return int The command exit code
  *
  * @throws \Exception
  * @throws BaseCommandException
  *
  * @see setCode()
  * @see execute()
  */
 public function run(InputInterface $input, OutputInterface $output)
 {
     $this->advanceExecutionPhase(RuntimeConfig::PHASE_PRE_RUN);
     $this->preRun($output);
     $this->advanceExecutionPhase(RuntimeConfig::PHASE_RUN);
     $exitCode = parent::run($input, $output);
     if ($this->getRuntimeConfig()->getExecutionPhase() !== RuntimeConfig::PHASE_POST_INITIALISE) {
         if ($this->getRuntimeConfig()->getExecutionPhase() == RuntimeConfig::PHASE_INITIALIZE_FAILED) {
             throw new BaseCommandException('It appears that you tried to continue execution despite the initialization ' . 'of the BaseCommand failing. This is a very dangerous idea as the behaviour is undefined');
         } else {
             throw new BaseCommandException('BaseCommand not initialized. Did you override the initialize() function ' . 'without calling parent::initialize() ?');
         }
     }
     $this->advanceExecutionPhase(RuntimeConfig::PHASE_POST_RUN);
     $this->postRun($input, $output, $exitCode);
     return $exitCode;
 }
开发者ID:afrihost,项目名称:BaseCommandBundle,代码行数:31,代码来源:BaseCommand.php

示例7: run

 public function run(InputInterface $input, OutputInterface $output)
 {
     $this->output = $output;
     $result = parent::run($input, $output);
     return $result;
 }
开发者ID:petit2m,项目名称:seriesTracker,代码行数:6,代码来源:BaseCommand.php

示例8: runCommand

 /**
  * Runs a command and returns a response if there was an error.
  *
  * @param ContainerAwareCommand $command
  * @param InputInterface|null   $input
  *
  * @return Response|null
  */
 private function runCommand(ContainerAwareCommand $command, InputInterface $input = null)
 {
     if (null === $input) {
         $input = new ArgvInput([]);
     }
     $output = new BufferedOutput(OutputInterface::VERBOSITY_NORMAL, true);
     $command->setContainer($this->container);
     $status = $command->run($input, $output);
     if ($status > 0) {
         return $this->render('console.html.twig', ['output' => $output->fetch()]);
     }
     return null;
 }
开发者ID:contao,项目名称:installation-bundle,代码行数:21,代码来源:InstallationController.php

示例9: run

 /**
  * Override framework function to add pre and post hooks around the parent functionality
  *
  * @param InputInterface  $input An InputInterface instance
  * @param OutputInterface $output An OutputInterface instance
  *
  * @return int The command exit code
  *
  * @throws \Exception
  * @throws BaseCommandException
  *
  * @see setCode()
  * @see execute()
  */
 public function run(InputInterface $input, OutputInterface $output)
 {
     if (is_null($this->runtimeConfig)) {
         throw new BaseCommandException("If you override the 'configure()' function, you need to call parent::configure()" . " in your overridden method in order for the BaseCommand to function correctly");
     }
     $this->advanceExecutionPhase(RuntimeConfig::PHASE_PRE_RUN);
     $this->preRun($output);
     $this->advanceExecutionPhase(RuntimeConfig::PHASE_RUN);
     $exitCode = parent::run($input, $output);
     if ($this->getRuntimeConfig()->getExecutionPhase() !== RuntimeConfig::PHASE_POST_INITIALISE) {
         throw new BaseCommandException('BaseCommand not initialized. Did you override the initialize() function ' . 'without calling parent::initialize() ?');
     }
     $this->advanceExecutionPhase(RuntimeConfig::PHASE_POST_RUN);
     $this->postRun($input, $output, $exitCode);
     return $exitCode;
 }
开发者ID:sarelvdwalt,项目名称:BaseCommandBundle,代码行数:30,代码来源:BaseCommand.php


注:本文中的Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand::run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。