Skip to content

Commit

Permalink
Making singleton access use a class property.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Apr 20, 2010
1 parent 7bf594f commit 661c768
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions cake/libs/router.php
Expand Up @@ -26,6 +26,13 @@
*/
class Router {

/**
* Instance for the singleton
*
* @var Router
*/
protected static $_instance;

/**
* Array of routes connected with Router::connect()
*
Expand Down Expand Up @@ -184,12 +191,10 @@ function __setPrefixes() {
* @return Router Instance of the Router.
*/
public static function &getInstance() {
static $instance = array();

if (!$instance) {
$instance[0] =& new Router();
if (!self::$_instance) {
self::$_instance = new Router();
}
return $instance[0];
return self::$_instance;
}

/**
Expand Down

0 comments on commit 661c768

Please sign in to comment.