|
PHP复制代码
function _set_overrides ($routing)
{
if ( ! is_array($routing))
{
return;
}
if (isset($routing['directory']))
{
$this->set_directory($routing['directory']);
$this->uri->rsegments['1']=$routing['directory'];
}
if (isset($routing['controller']) AND $routing['controller'] != '')
{
$this->set_class($routing['controller']);
$n=isset($routing['directory'])? 2:1;
$this->uri->rsegments[$n]=$routing['controller'];
}
if (isset($routing['function']))
{
$routing['function'] = ($routing['function'] == '') ? 'index' : $routing['function'];
$this->set_method($routing['function']);
$n=isset($routing['directory'])? 3:2;
$this->uri->rsegments[$n]=$routing['function'];
}
}
复制代码PHP复制代码
function _set_overrides ($routing)
{
if ( ! is_array($routing))
{
return;
}
if (isset($routing['directory']))
{
$this->set_directory($routing['directory']);
}
if (isset($routing['controller']) AND $routing['controller'] != '')
{
$this->set_class($routing['controller']);
}
if (isset($routing['function']))
{
$routing['function'] = ($routing['function'] == '') ? 'index' : $routing['function'];
$this->set_method($routing['function']);
}
}
复制代码
这是核心类Router.php 的一个函数。如果你在index.php文件中指定了$routing的值,此函数在系统初始化时被调用,用来覆盖routs.php配置文件里的重新路由信息的规则。上面是我自己写的扩展,下面是源文件里的。差别主要是,调用此函数覆盖routs.php的默认配置后,是否同步更新uri类的rsegments属性。我觉得应该同步更新,这样更合理些。不知大家怎么看?
|
评分
-
查看全部评分
|