コード例 #1
0
 /**
  * @inheritdoc
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $actions = $input->getArgument('action');
     if (empty($actions)) {
         $actions = array_keys($this->manager->getExecutors());
     }
     $states = $input->getOption('state');
     $pheanstalk = $this->manager->getPheanstalk();
     foreach ($actions as $action) {
         try {
             $stats = $pheanstalk->statsTube($action);
             $amount = 0;
             foreach ($states as $state) {
                 $amount += $stats['current-jobs-' . $state];
             }
             $output->writeln(sprintf('Clearing <info>%d %s jobs</info> with <info>%s</info> status', $amount, $action, implode(', ', $states)));
             $this->manager->clear($action, $states);
             $output->writeln(['<info>Done!</info>', '']);
         } catch (ServerException $e) {
             if (false === strpos($e->getMessage(), 'NOT_FOUND')) {
                 throw $e;
             }
         }
     }
 }
コード例 #2
0
 /**
  * @expectedException        \InvalidArgumentException
  * @expectedExceptionMessage $state must be one of
  */
 public function testClearInvalidState()
 {
     $executor = new ObjectExecutor();
     $action = $executor->getName();
     $this->manager->addExecutor($executor);
     $this->manager->clear($action, ['foo']);
 }