private static function cached($actionContext) {
        $httpContext = $actionContext->getHttpContext();
        $request = $httpContext->getRequest();

        // TODO: support POST
        if ($request->isPost()) {
            return false;
        }

        $cacheSettings = InternalHelper::getStaticPropertyValue('\\PhpMvc\\OutputCache', 'settings');
        $actionName = $actionContext->getActionName();

        if (!isset($cacheSettings[$actionName])) {
            $cacheSettings[$actionName] = array();
        }

        if (!isset($cacheSettings['.'])) {
            $cacheSettings['.'] = array();
        }

        if (empty($cacheSettings[$actionName]) && empty($cacheSettings['.'])) {
            return false;
        }

        // location
        if (!empty($cacheSettings[$actionName]['location'])) {
            $location = intval($cacheSettings[$actionName]['location']);
        }
        elseif (!empty($cacheSettings['.']['location'])) {
            $location = intval($cacheSettings['.']['location']);
        }
        else {
            $location = OutputCacheLocation::ANY;
        }

        if (array_search($location, array(OutputCacheLocation::ANY, OutputCacheLocation::SERVER, OutputCacheLocation::SERVER_AND_CLIENT)) === false) {
            return false;
        }

        // vary by parameters
        $params = self::getCacheParams($actionContext, $cacheSettings, 'varyByParam', array_merge($request->get(), $actionContext->getArguments()));

        // vary by headers
        $headers = self::getCacheParams($actionContext, $cacheSettings, 'varyByHeader', $request->headers());

        // vary by custom handlers
        $custom = self::getCacheParams($actionContext, $cacheSettings, 'varyByCustom');

        // check cache
        $response = $httpContext->getResponse();
        $cache = $httpContext->getCache();

        $cacheKey = 'output_' . $request->path() . '_params=' . implode('&', $params) . '_http=' . implode('&', $headers) . '_custom=' . implode('&', $custom);

        if (($cachedResponse = $cache->get($cacheKey)) !== null) {
            $response->setHeaders($cachedResponse['headers']);
            $response->setCookies($cachedResponse['cookies']);
            $response->setStatusCode($cachedResponse['statusCode']);
            $response->setStatusDescription($cachedResponse['statusDescription']);
            $response->writeFile($cachedResponse['files']);
            $response->write($cachedResponse['output']);
            $response->end();
            return true;
        }

        InternalHelper::setPropertyValue($actionContext, 'cacheKey', $cacheKey);

        return false;
    }
private static function cached($actionContext) {
        $httpContext = $actionContext->getHttpContext();
        $request = $httpContext->getRequest();

        // TODO: support POST
        if ($request->isPost()) {
            return false;
        }

        $cacheSettings = InternalHelper::getStaticPropertyValue('\\PhpMvc\\OutputCache', 'settings');
        $actionName = $actionContext->getActionName();

        if (!isset($cacheSettings[$actionName])) {
            $cacheSettings[$actionName] = array();
        }

        if (!isset($cacheSettings['.'])) {
            $cacheSettings['.'] = array();
        }

        if (empty($cacheSettings[$actionName]) && empty($cacheSettings['.'])) {
            return false;
        }

        // location
        if (!empty($cacheSettings[$actionName]['location'])) {
            $location = intval($cacheSettings[$actionName]['location']);
        }
        elseif (!empty($cacheSettings['.']['location'])) {
            $location = intval($cacheSettings['.']['location']);
        }
        else {
            $location = OutputCacheLocation::ANY;
        }

        if (array_search($location, array(OutputCacheLocation::ANY, OutputCacheLocation::SERVER, OutputCacheLocation::SERVER_AND_CLIENT)) === false) {
            return false;
        }

        // vary by parameters
        $params = self::getCacheParams($actionContext, $cacheSettings, 'varyByParam', array_merge($request->get(), $actionContext->getArguments()));

        // vary by headers
        $headers = self::getCacheParams($actionContext, $cacheSettings, 'varyByHeader', $request->headers());

        // vary by custom handlers
        $custom = self::getCacheParams($actionContext, $cacheSettings, 'varyByCustom');

        // check cache
        $response = $httpContext->getResponse();
        $cache = $httpContext->getCache();

        $cacheKey = 'output_' . $request->path() . '_params=' . implode('&', $params) . '_http=' . implode('&', $headers) . '_custom=' . implode('&', $custom);

        if (($cachedResponse = $cache->get($cacheKey)) !== null) {
            $response->setHeaders($cachedResponse['headers']);
            $response->setCookies($cachedResponse['cookies']);
            $response->setStatusCode($cachedResponse['statusCode']);
            $response->setStatusDescription($cachedResponse['statusDescription']);
            $response->writeFile($cachedResponse['files']);
            $response->write($cachedResponse['output']);
            $response->end();
            return true;
        }

        InternalHelper::setPropertyValue($actionContext, 'cacheKey', $cacheKey);

        return false;
    }
private static function cached ( $ actionContext ) { $ httpContext = $ actionContext -> getHttpContext ( ) ; $ request = $ httpContext -> getRequest ( ) ; // TODO: support POST if ( $ request -> isPost ( ) ) { return false ; } $ cacheSettings = InternalHelper :: getStaticPropertyValue ( '\\PhpMvc\\OutputCache' , 'settings' ) ; $ actionName = $ actionContext -> getActionName ( ) ; if ( ! isset ( $ cacheSettings [ $ actionName ] ) ) { $ cacheSettings [ $ actionName ] = array ( ) ; } if ( ! isset ( $ cacheSettings [ '.' ] ) ) { $ cacheSettings [ '.' ] = array ( ) ; } if ( empty ( $ cacheSettings [ $ actionName ] ) && empty ( $ cacheSettings [ '.' ] ) ) { return false ; } // location if ( ! empty ( $ cacheSettings [ $ actionName ] [ 'location' ] ) ) { $ location = intval ( $ cacheSettings [ $ actionName ] [ 'location' ] ) ; } elseif ( ! empty ( $ cacheSettings [ '.' ] [ 'location' ] ) ) { $ location = intval ( $ cacheSettings [ '.' ] [ 'location' ] ) ; } else { $ location = OutputCacheLocation :: ANY ; } if ( array_search ( $ location , array ( OutputCacheLocation :: ANY , OutputCacheLocation :: SERVER , OutputCacheLocation :: SERVER_AND_CLIENT ) ) === false ) { return false ; } // vary by parameters $ params = self :: getCacheParams ( $ actionContext , $ cacheSettings , 'varyByParam' , array_merge ( $ request -> get ( ) , $ actionContext -> getArguments ( ) ) ) ; // vary by headers $ headers = self :: getCacheParams ( $ actionContext , $ cacheSettings , 'varyByHeader' , $ request -> headers ( ) ) ; // vary by custom handlers $ custom = self :: getCacheParams ( $ actionContext , $ cacheSettings , 'varyByCustom' ) ; // check cache $ response = $ httpContext -> getResponse ( ) ; $ cache = $ httpContext -> getCache ( ) ; $ cacheKey = 'output_' . $ request -> path ( ) . '_params=' . implode ( '&' , $ params ) . '_http=' . implode ( '&' , $ headers ) . '_custom=' . implode ( '&' , $ custom ) ; if ( ( $ cachedResponse = $ cache -> get ( $ cacheKey ) ) !== null ) { $ response -> setHeaders ( $ cachedResponse [ 'headers' ] ) ; $ response -> setCookies ( $ cachedResponse [ 'cookies' ] ) ; $ response -> setStatusCode ( $ cachedResponse [ 'statusCode' ] ) ; $ response -> setStatusDescription ( $ cachedResponse [ 'statusDescription' ] ) ; $ response -> writeFile ( $ cachedResponse [ 'files' ] ) ; $ response -> write ( $ cachedResponse [ 'output' ] ) ; $ response -> end ( ) ; return true ; } InternalHelper :: setPropertyValue ( $ actionContext , 'cacheKey' , $ cacheKey ) ; return false ; }
Checks the cache and outputs the result if there is data in the cache for the current request.

@param ActionContext $actionContext The action context.

@return bool
Checks the cache and outputs the result if there is data in the cache for the current request .