Skip to content

Commit

Permalink
adds redirectTo method
Browse files Browse the repository at this point in the history
Adds method `redirectTo` which is a shortcut for `redirect(urlfor(..))`

Helps making the code more readable by encapsulating a common pattern.
  • Loading branch information
maldoinc committed Jul 11, 2014
1 parent 4906b77 commit a727fba
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Slim/Slim.php
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,18 @@ public function redirect($url, $status = 302)
$this->response->redirect($url, $status);
$this->halt($status);
}

/**
* RedirectTo
*
* Redirects to a specific named route
*
* @param string $url The route name
* @param array $params Associative array of URL parameters and replacement values
*/
public function redirectTo($route, $params = array(), $status = 302){
$this->redirect($this->urlFor($route, $params), $status);
}

/********************************************************************************
* Flash Messages
Expand Down

0 comments on commit a727fba

Please sign in to comment.