mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Adding constructor to Router.
Adding __setPrefixes to initialize prefixes and merge Routing.admin with new Routing.prefixes.
This commit is contained in:
parent
2f46f39225
commit
3904c6f7b5
2 changed files with 27 additions and 3 deletions
|
@ -164,6 +164,31 @@ class Router {
|
||||||
*/
|
*/
|
||||||
var $__defaultsMapped = false;
|
var $__defaultsMapped = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for Router.
|
||||||
|
* Builds __prefixes
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
**/
|
||||||
|
function Router() {
|
||||||
|
$this->__setPrefixes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the Routing prefixes.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @access private
|
||||||
|
**/
|
||||||
|
function __setPrefixes() {
|
||||||
|
$routing = Configure::read('Routing');
|
||||||
|
if (isset($routing['admin'])) {
|
||||||
|
$this->__prefixes[] = $this->__admin = $routing['admin'];
|
||||||
|
}
|
||||||
|
if (isset($routing['prefixes'])) {
|
||||||
|
$this->__prefixes = array_merge($this->__prefixes, $routing['prefixes']);
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Gets a reference to the Router object instance
|
* Gets a reference to the Router object instance
|
||||||
*
|
*
|
||||||
|
@ -176,7 +201,6 @@ class Router {
|
||||||
|
|
||||||
if (!$instance) {
|
if (!$instance) {
|
||||||
$instance[0] =& new Router();
|
$instance[0] =& new Router();
|
||||||
$instance[0]->__admin = Configure::read('Routing.admin');
|
|
||||||
}
|
}
|
||||||
return $instance[0];
|
return $instance[0];
|
||||||
}
|
}
|
||||||
|
@ -722,7 +746,7 @@ class Router {
|
||||||
foreach (get_class_vars('Router') as $key => $val) {
|
foreach (get_class_vars('Router') as $key => $val) {
|
||||||
$_this->{$key} = $val;
|
$_this->{$key} = $val;
|
||||||
}
|
}
|
||||||
$_this->__admin = Configure::read('Routing.admin');
|
$_this->__setPrefixes();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1655,7 +1655,7 @@ class RouterTest extends CakeTestCase {
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$result = Router::prefixes();
|
$result = Router::prefixes();
|
||||||
$expected = array('protected', 'admin');
|
$expected = array('admin', 'protected');
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue