Example #1
0
 /**
  * @param Application $application
  * @return false|mixed
  * @throws \ErrorException
  */
 public function preHandle(Application $application)
 {
     $request = $application->getRequest();
     $application->setCacheKeys($request);
     $cache = $application->getCache();
     if ($cache->exists($application->getCacheKey('response')) && !$request->isAjax()) {
         return $cache->get($application->getCacheKey('response'));
     } elseif ($cache->exists($application->getCacheKey('route')) && $application->getConfig()->get('app.cacheRoutes', true)) {
         $route = $cache->get($application->getCacheKey('route'));
         if ($route instanceof Route) {
             return $this->getRouter()->run($route);
         }
     }
     return false;
 }