public function onPurge(QueuePurgeEvent $event)
 {
     try {
         # purge jobs that have been completed or failed
         # before x date
         $result = $this->gateway->deleteQuery()->start()->filterByStateFail()->filterByStateFinish()->filterByAddedBefore($event->getBeforeDate())->end()->delete();
         $event->setResult($this->gateway->rowsAffected());
     } catch (DBALGatewayException $e) {
         $event->setResult(false);
         throw new LaterJobException($e->getMessage(), 0, $e);
     }
 }
Beispiel #2
0
 public function testQueuePurgeEvent()
 {
     $before = new DateTime();
     $result = true;
     $purge = new QueuePurgeEvent($before);
     $purge->setResult($result);
     $this->assertEquals($result, $purge->getResult());
     $this->assertEquals($before, $purge->getBeforeDate());
 }
 /**
  *  Log events that occur from queue
  *
  *  @access public
  *  @param QueuePurgeEvent $event 
  */
 public function logQueuePurgeEvent(QueuePurgeEvent $event)
 {
     $this->log->info('QueuePurgeEvent:: Purge jobs from queue using params', array('before' => $event->getBeforeDate()));
 }
 /**
  *  Log events that occur from queue
  *
  *  @access public
  *  @param QueuePurgeEvent $event 
  */
 public function logQueuePurgeEvent(QueuePurgeEvent $event)
 {
     $this->output->writeln('QueuePurgeEvent:: Purge jobs from queue using params ' . json_encode(array('before' => $event->getBeforeDate())));
 }