Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refs #4375 - Parameter order for HTTP/Controller::redirect() #233

Merged
merged 1 commit into from
Mar 27, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions classes/Kohana/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ public function after()
*
* Proxies to the [HTTP::redirect] method.
*
* @param int $code HTTP Status code to use for the redirect
* @param string $uri URI to redirect to
* @param int $code HTTP Status code to use for the redirect
* @throws HTTP_Exception
*/
public static function redirect($code = 302, $uri = '')
public static function redirect($uri = '', $code = 302)
{
return HTTP::redirect($code, $uri);
return HTTP::redirect($uri, $code);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions classes/Kohana/HTTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ abstract class Kohana_HTTP {
/**
* Issues a HTTP redirect.
*
* @param int $code HTTP Status code to use for the redirect
* @param string $uri URI to redirect to
* @param int $code HTTP Status code to use for the redirect
* @throws HTTP_Exception
*/
public static function redirect($code = 302, $uri = '')
public static function redirect($uri = '', $code = 302)
{
throw HTTP_Exception::factory($code)->location($uri);
}
Expand Down
4 changes: 2 additions & 2 deletions guide/kohana/mvc/controllers.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ A user login action.
// Try to login
if (Auth::instance()->login($this->request->post('username'), $this->request->post('password')))
{
$this->redirect(302, 'home');
$this->redirect('home', 302);
}

$view->errors = 'Invalid email or password';
Expand All @@ -154,7 +154,7 @@ You can check what action has been requested (via `$this->request->action`) and
// If this user doesn't have the admin role, and is not trying to login, redirect to login
if ( ! Auth::instance()->logged_in('admin') AND $this->request->action !== 'login')
{
$this->redirect(302, 'admin/login');
$this->redirect('admin/login', 302);
}
}

Expand Down
2 changes: 1 addition & 1 deletion guide/kohana/security/validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ Next, we need a controller and action to process the registration, which will be
$user->register($post);

// Always redirect after a successful POST to prevent refresh warnings
$this->redirect(302, 'user/profile');
$this->redirect('user/profile', 302);
}

// Validation failed, collect the errors
Expand Down
4 changes: 2 additions & 2 deletions guide/kohana/upgrading.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ Examples:

Redirects are no longer issued against the [Request] object. The new syntax from inside a controler is:

$this->redirect(302, 'http://www.google.com');
$this->redirect('http://www.google.com', 302);

or from outside a controller:

HTTP::redirect(302, 'http://www.google.com');
HTTP::redirect('http://www.google.com', 302);

## Custom Error Pages (HTTP 500, 404, 403, 401 etc)

Expand Down