public function isCacheValid($api, $class)
{
// get the modified time of the $class
try {
$reflection = new \ReflectionClass($class);
} catch (\Exception $e) {
throw new RestException('Unable to validate the cache for ' . $class . '. ' . $e->getMessage());
}
$classModTime = filemtime($reflection->getFileName());
return $this->cacheDriver->isFresh($api, $class, 'current', $classModTime);
}
/** * Registers the class and creates a compile cache version of it. * * @throws RestException */ private function registerClass() { try { if (!$this->cacheInstance->isCacheValid($this->api, $this->class) || $this->isDevelopment()) { $this->parseClass(); } } catch (\Exception $e) { $exception = new RestException('Unable to register class "' . $this->class . '". ' . $e->getMessage()); $exception->setRequestedClass($this->class); throw $exception; } }