bundle/Controller/Controller.php
protected function processCacheSettings(Request $request, Response $response): void
    {
        $defaultSharedMaxAge = $this->getConfigResolver()->getParameter('view.shared_max_age', 'ngsite');

        $cacheSettings = $request->attributes->get('cacheSettings');
        if (!is_array($cacheSettings)) {
            $cacheSettings = ['sharedMaxAge' => $defaultSharedMaxAge];
        }

        $public = true;

        if (isset($cacheSettings['sharedMaxAge'])) {
            $response->setSharedMaxAge($cacheSettings['sharedMaxAge']);
            if (empty($cacheSettings['sharedMaxAge'])) {
                $public = false;
            }
        } elseif (isset($cacheSettings['maxAge'])) {
            $response->setMaxAge($cacheSettings['maxAge']);
            if (empty($cacheSettings['maxAge'])) {
                $public = false;
            }
        } else {
            $response->setSharedMaxAge($defaultSharedMaxAge);
        }

        $public ? $response->setPublic() : $response->setPrivate();
    }
protected function processCacheSettings(Request $request, Response $response): void
    {
        $defaultSharedMaxAge = $this->getConfigResolver()->getParameter('view.shared_max_age', 'ngsite');

        $cacheSettings = $request->attributes->get('cacheSettings');
        if (!is_array($cacheSettings)) {
            $cacheSettings = ['sharedMaxAge' => $defaultSharedMaxAge];
        }

        $public = true;

        if (isset($cacheSettings['sharedMaxAge'])) {
            $response->setSharedMaxAge($cacheSettings['sharedMaxAge']);
            if (empty($cacheSettings['sharedMaxAge'])) {
                $public = false;
            }
        } elseif (isset($cacheSettings['maxAge'])) {
            $response->setMaxAge($cacheSettings['maxAge']);
            if (empty($cacheSettings['maxAge'])) {
                $public = false;
            }
        } else {
            $response->setSharedMaxAge($defaultSharedMaxAge);
        }

        $public ? $response->setPublic() : $response->setPrivate();
    }
protected function processCacheSettings ( Request $ request , Response $ response ) : void { $ defaultSharedMaxAge = $ this -> getConfigResolver ( ) -> getParameter ( 'view.shared_max_age' , 'ngsite' ) ; $ cacheSettings = $ request -> attributes -> get ( 'cacheSettings' ) ; if ( ! is_array ( $ cacheSettings ) ) { $ cacheSettings = [ 'sharedMaxAge' => $ defaultSharedMaxAge ] ; } $ public = true ; if ( isset ( $ cacheSettings [ 'sharedMaxAge' ] ) ) { $ response -> setSharedMaxAge ( $ cacheSettings [ 'sharedMaxAge' ] ) ; if ( empty ( $ cacheSettings [ 'sharedMaxAge' ] ) ) { $ public = false ; } } elseif ( isset ( $ cacheSettings [ 'maxAge' ] ) ) { $ response -> setMaxAge ( $ cacheSettings [ 'maxAge' ] ) ; if ( empty ( $ cacheSettings [ 'maxAge' ] ) ) { $ public = false ; } } else { $ response -> setSharedMaxAge ( $ defaultSharedMaxAge ) ; } $ public ? $ response -> setPublic ( ) : $ response -> setPrivate ( ) ; }
Configures the response with provided cache settings.
Configures the response with provided cache settings .