Example #1
0
 /**
  *	Redirect
  *	Redirect the response
  *	@param string $destinationUrl
  *	@param int $statusCode
  *	@return \Touchbase\Control\HTTPResponse
  */
 public function redirect($destinationUrl, $statusCode = 302)
 {
     if (is_numeric($destinationUrl) && $destinationUrl < 0) {
         $routeHistory = Router::routeHistory();
         $destinationUrl = $routeHistory[count($routeHistory) - abs($destinationUrl)];
     }
     if (Router::isRelativeURL($destinationUrl)) {
         $destinationUrl = Router::buildPath(SITE_URL, $destinationUrl);
     }
     $statusCode = in_array($statusCode, $this->redirectCodes) ? $statusCode : 302;
     $this->setStatusCode($statusCode);
     $this->addHeader('Location', $destinationUrl);
     return $this;
 }