Beispiel #1
0
 public function perform()
 {
     try {
         $closure = $this->getClosure();
         Resque_Event::trigger('beforePerform', $this);
         Resque_Job_Closure::invokeSerializableClosure($closure, $this, $this->getArguments());
         Resque_Event::trigger('afterPerform', $this);
     } catch (Resque_Job_DontPerform $e) {
         return false;
     }
     return true;
 }
Beispiel #2
0
 /**
  * Create a new job and save it to the specified queue.
  *
  * @param string $queue The name of the queue to place the job in.
  * @param string $class The name of the class that contains the code to execute the job.
  * @param array $args Any optional arguments that should be passed when the job is executed.
  * @param boolean $trackStatus Set to true to be able to monitor the status of a job.
  * @param string $method method name to invoke in job class.
  * @return string
  */
 public static function enqueue($queue, $call, $args = null, $trackStatus = false, $method = 'fire')
 {
     if ($call instanceof Closure) {
         $serialized = serialize(new SerializableClosure($call));
         $result = Resque_Job_Closure::create($queue, $serialized, $args, $trackStatus);
         if ($result) {
             Resque_Event::trigger('afterEnqueue', array('class' => $serialized, 'args' => $args, 'queue' => $queue, 'id' => $result));
         }
         return $result;
     }
     $result = Resque_Job_Class::create($queue, $call, $args, $trackStatus, $method);
     if ($result) {
         Resque_Event::trigger('afterEnqueue', array('class' => $call, 'args' => $args, 'queue' => $queue, 'id' => $result, 'method' => $method));
     }
     return $result;
 }