/**
  * {@inheritdoc}
  */
 public function createPerformantJob(JobInterface $job)
 {
     $target = $job->getJobClass();
     if ($this->container->has($target)) {
         return $this->container->get($target);
     }
     return parent::createPerformantJob($job);
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function createPerformantJob(JobInterface $job)
 {
     $class = $job->getJobClass();
     if (false === class_exists($class)) {
         throw new JobNotFoundException('Could not find job class "' . $class . '"');
     }
     $instance = new $class();
     return $instance;
 }
예제 #3
0
 function it_should_throw_on_job_not_found(JobInterface $job)
 {
     $job->getJobClass()->shouldBeCalled()->willReturn('Resque\\Tests\\Jobs\\NonExistent');
     $this->shouldThrow('Resque\\Component\\Job\\Exception\\JobNotFoundException')->duringCreatePerformantJob($job);
 }
예제 #4
0
파일: Job.php 프로젝트: php-resque/resque
 /**
  * {@inheritdoc}
  */
 public static function matchFilter(JobInterface $job, $filter = array())
 {
     $filters = array('id' => function (JobInterface $job, $filter) {
         if (isset($filter['id'])) {
             return $filter['id'] === $job->getId();
         }
         return null;
     }, 'class' => function (JobInterface $job, $filter) {
         if (isset($filter['class'])) {
             return $filter['class'] === $job->getJobClass();
         }
         return null;
     });
     $results = array();
     foreach ($filters as $filterName => $filterCallback) {
         $result = $filterCallback($job, $filter);
         // Discard null results as that is the callback telling us it's conditional is not set.
         if (null === $result) {
             continue;
         }
         $results[$filterName] = $result;
     }
     return count(array_unique($results)) === 1 && reset($results) === true;
 }