setTtl() public method

Set the max-age for client caching
public setTtl ( integer $ttl ) : self
$ttl integer Time to cache in seconds
return self
Ejemplo n.º 1
0
 /**
  * Filter an AjaxResponse through a plugin hook
  *
  * @param AjaxResponse $api_response The API Response
  * @param string       $hook_type    The hook type. If given, the response will be filtered by hook
  *
  * @return AjaxResponse
  */
 private function filterApiResponse(AjaxResponse $api_response, $hook_type = '')
 {
     $api_response->setTtl($this->input->get('response_ttl', 0, false));
     if ($hook_type) {
         $hook = AjaxResponse::RESPONSE_HOOK;
         $api_response = $this->hooks->trigger($hook, $hook_type, null, $api_response);
         if (!$api_response instanceof AjaxResponse) {
             throw new \RuntimeException("The value returned by hook [{$hook}, {$hook_type}] was not an ApiResponse");
         }
     }
     return $api_response;
 }