-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
Apply patch from 'Tigran Gabrielyan'. Allows you to set the default route class used for all future routes. Fixes #2435
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -152,6 +152,23 @@ class Router { | |
*/ | ||
protected static $_initialState = array(); | ||
|
||
/** | ||
* Default route class to use | ||
* | ||
* @var string | ||
*/ | ||
protected static $_routeClass = 'CakeRoute'; | ||
|
||
/** | ||
* Set the default rotue class to use | ||
* | ||
* @param sting $routeClass to set as default | ||
* @return void | ||
*/ | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
tigrang
Contributor
|
||
public static function defaultRouteClass($routeClass) { | ||
self::$_routeClass = $routeClass; | ||
} | ||
|
||
/** | ||
* Sets the Routing prefixes. | ||
* | ||
|
@@ -259,7 +276,7 @@ public static function connect($route, $defaults = array(), $options = array()) | |
if (empty($options['action'])) { | ||
$defaults += array('action' => 'index'); | ||
} | ||
$routeClass = 'CakeRoute'; | ||
$routeClass = self::$_routeClass; | ||
if (isset($options['routeClass'])) { | ||
$routeClass = $options['routeClass']; | ||
if (!is_subclass_of($routeClass, 'CakeRoute')) { | ||
|
How about making this function a getter too so that if you pass it null param it returns the current default route class name. That could be useful for someone.