Ejemplo n.º 1
0
 /**
  * @param MvcEvent $e
  * @return mixed | void
  */
 public function onDispatch(MvcEvent $e)
 {
     $removeModel = new RemoveModel();
     if (!$this->remover->remove($this->getResource())) {
         $removeModel->fail();
     } else {
         $removeModel->success();
     }
     $e->setResult($removeModel);
 }
 /**
  * @return bool
  */
 public function clean()
 {
     $qb = $this->getRepository()->createQueryBuilder('r');
     $date = new \DateTime();
     $dateInterval = new \DateInterval('PT' . $this->options->getTtl() . 'S');
     $date->sub($dateInterval);
     $query = $qb->where('r.createdTimestamp < :timestamp')->andWhere($qb->expr()->eq('r.temporary', '1'))->setParameter('timestamp', $date)->getQuery();
     $response = true;
     foreach ($query->getResult() as $resource) {
         if (!$this->remover->remove($resource)) {
             $response = false;
         }
     }
     return $response;
 }