API CHANGE Static functions Director::redirect(), Director::redirectBack(),

Director::set_status_code(), Director::get_status_code() and
Director::redirected_to() are now deprecated. Use Controller->redirect(),
Controller->redirectBack(), Controller->getResponse()->setStatusCode(),
Controller->getResponse()->getStatusCode() and
Controller->redirectedTo() respectively.
This commit is contained in:
Sean Harvey 2012-05-23 21:48:06 +12:00
parent 4267c0312a
commit f7f67d90a5
2 changed files with 9 additions and 2 deletions

View File

@ -434,8 +434,7 @@ class Controller extends RequestHandler implements TemplateGlobalProvider {
}
/**
* Redirct to the given URL.
* It is generally recommended to call Director::redirect() rather than calling this function directly.
* Redirect to the given URL.
*/
function redirect($url, $code=302) {
if(!$this->response) $this->response = new SS_HTTPResponse();

View File

@ -397,33 +397,41 @@ class Director implements TemplateGlobalProvider {
/**
* Redirect to another page.
* @deprecated 2.5 Use Controller->redirect()
* - $url can be an absolute URL
* - or it can be a URL relative to the "site base"
* - if it is just a word without an slashes, then it redirects to another action on the current controller.
*/
static function redirect($url, $code=302) {
Deprecation::notice('2.5', 'Use Controller->redirect() instead.');
Controller::curr()->redirect($url, $code);
}
/**
* Tests whether a redirection has been requested.
* @deprecated 2.5 Use Controller->redirectedTo() instead
* @return string If redirect() has been called, it will return the URL redirected to. Otherwise, it will return null;
*/
static function redirected_to() {
Deprecation::notice('2.5', 'Use Controller->redirectedTo() instead.');
return Controller::curr()->redirectedTo();
}
/**
* Sets the HTTP status code
* @deprecated 2.5 Use Controller->getResponse()->setStatusCode() instead
*/
static function set_status_code($code) {
Deprecation::notice('2.5', 'Use Controller->getResponse()->setStatusCode() instead');
return Controller::curr()->getResponse()->setStatusCode($code);
}
/**
* Returns the current HTTP status code
* @deprecated 2.5 Use Controller->getResponse()->getStatusCode() instead
*/
static function get_status_code() {
Deprecation::notice('2.5', 'Use Controller->getResponse()->getStatusCode() instead');
return Controller::curr()->getResponse()->getStatusCode();
}