protected function _setResponseToCache(__IRequest &$request, __IResponse &$response) { $uri = $request->getUri(); if ($uri != null) { $route = $uri->getRoute(); if ($route != null) { if ($route->getCache()) { //only cache anonymous view: if ($response->isCacheable()) { $response_snapshot = new __ResponseSnapshot($response); $cache = __ApplicationContext::getInstance()->getCache(); $cache->setData('responseSnapshot::' . $request->getUniqueCode(), $response_snapshot, $route->getCacheTtl()); } } else { if ($route->getSuperCache()) { //only cache anonymous view: if ($response->isCacheable()) { $target_url_components = parse_url($uri->getAbsoluteUrl()); $path = $target_url_components['path']; $dir = dirname($path); $file = basename($path); $response_content = $response->getContent() . "\n<!-- supercached -->"; $cache_ttl = $route->getCacheTtl(); $server_dir = $_SERVER['DOCUMENT_ROOT'] . $dir; if (is_dir($server_dir) && is_writable($server_dir)) { $file_handler = fopen($server_dir . DIRECTORY_SEPARATOR . $file, "w+"); fputs($file_handler, $response_content); fclose($file_handler); } else { $exception = __ExceptionFactory::getInstance()->createException('Directory not found to supercache: ' . $server_dir); __ErrorHandler::getInstance()->logException($exception); } } } } } } }
function handleError($errno, $errstr, $errfile, $errline) { $error_exception = new ErrorException($errstr, 0, $errno, $errfile, $errline); __ErrorHandler::getInstance()->handleException($error_exception); return false; }