/** * Seed the file cache with any files accessed after a date * * @param \Jazzee\FileStore $fileStore * @param \DateTime $lastAccessedSince * @return int */ public function seedFileCache(\Jazzee\FileStore $fileStore, \DateTime $lastAccessedSince) { $query = $this->_em->createQuery('SELECT f.hash FROM Jazzee\\Entity\\File f WHERE f.lastAccess > :lastAccess'); $query->setParameter('lastAccess', $lastAccessedSince); $cached = 0; foreach ($query->execute() as $arr) { if ($fileStore->seedCache($arr['hash'])) { $cached++; } } return $cached; }
public function actionIndex() { if ($this->semaphore()) { $this->setLimits(); $this->log('Cron run started'); foreach ($this->listControllers() as $controller) { \Foundation\VC\Config::includeController($controller); $class = \Foundation\VC\Config::getControllerClassName($controller); if (method_exists($class, 'runCron')) { if (self::VERBOSE_LOGS) { $this->log("Admin controller {$controller} job started"); } $class::runCron($this); $this->_em->flush(); } //reset the max execution time and memory limit after every admin script is included because some override this $this->setLimits(); } foreach ($this->_em->getRepository('\\Jazzee\\Entity\\PageType')->findAll() as $pageType) { $class = $pageType->getClass(); if (method_exists($class, 'runCron')) { if (self::VERBOSE_LOGS) { $this->log("Page type {$class} job started"); } $class::runCron($this); $this->_em->flush(); } $this->setLimits(); } foreach ($this->_em->getRepository('\\Jazzee\\Entity\\ElementType')->findAll() as $elementType) { $class = $elementType->getClass(); if (method_exists($class, 'runCron')) { if (self::VERBOSE_LOGS) { $this->log("Element type {$class} job started"); } $class::runCron($this); $this->_em->flush(); } $this->setLimits(); } //Perform applicant actions \Foundation\VC\Config::includeController('apply_applicant'); if (self::VERBOSE_LOGS) { $this->log("Controller apply_applicant job started"); } ApplyApplicantController::runCron($this); //File store actions \Jazzee\FileStore::runCron($this); //clear the semephore $this->setVar('adminCronSemephore', false); $this->log('Cron run finished'); } }