/** * Pre-filter parses request to see if the client already has the most * up-to-date copy. * * @param T_Response $response encapsulated response to filter * @throws T_Response alternative response */ protected function doPreFilter(T_Response $response) { if ($this->isCurrent()) { // client has current copy $alt = new T_Response(304); $this->setHeader($alt); $response->abort(); throw $alt; } else { $this->setHeader($response); } }
function testisAbortedReturnTrueOnceIsAborted() { $this->response->appendFilter($this->filter[0]); $this->response->abort(); $this->assertTrue($this->response->isAborted()); }
/** * Error occurred and alternative response required. * * If a custom 404 response, etc. is required, this controller method * can be overridden to build the custom response. * * @param int $status Status code (e.g. 404,etc) * @param T_Response $response old response (to abort) */ protected function respondWithStatus($status, T_Response $response) { $response->abort(); throw $this->like('T_Response', array('status' => $status)); }
/** * Add aborted flag to abort method */ function abort() { $this->is_aborted = true; parent::abort(); }
/** * Prepare-filter forwards to get if form was present and valid. * * At this point, the request has not been sent, but has been created and is about to be. * If the request is valid, we want to skip out *before* the form is sent and simply * redirect. * * @param T_Response $response encapsulated response to filter */ protected function doPrepareFilter(T_Response $response) { if ($this->form->isPresent() && $this->form->isValid() && $this->forward) { // POST request is successful, therefore redirect to GET so the // back button cannot be used to repeat the request. $response->abort(); throw new T_Response_Redirect($this->forward->getUrl()); } }