Go to the documentation of this file.00001 <?php
00020 abstract class axBaseController {
00021
00026 protected static $_request;
00027
00032 protected static $_response;
00033
00044 public static function _init (axRequest &$request, axResponse &$response) {
00045 self::setRequest($request);
00046 self::setResponse($response);
00047 }
00048
00055 final protected static function setRequest (axRequest &$request) {
00056 self::$_request = $request;
00057 }
00058
00065 final protected static function setResponse (axResponse &$response) {
00066 self::$_response = $response;
00067 }
00068
00086 final protected static function forward ($controller, $action = "index") {
00087 if (strpos($controller, 'Controller') === false)
00088 throw new RuntimeException("$controller is not a valid controller name", 2040);
00089
00090 if ($controller == 'axBaseController')
00091 throw new RuntimeException("Redirection is impossible on $controller", 2041);
00092
00093 if (!axAutoloader::load($controller))
00094 throw new BadMethodCallException("Cannot find $controller", 2042);
00095
00096 throw new axForwardException($controller, $action);
00097 }
00098
00111 final protected static function redirect ($url, $method = axRedirectException::REDIRECT_REFRESH) {
00112 if (!$url || !filter_var($url, FILTER_VALIDATE_URL))
00113 throw new InvalidArgumentException("First parameter is expected to be a valid url", 2043);
00114
00115 throw new axRedirectException($url, $method);
00116 }
00117 }