Authored by hf

do domain merge support old code

... ... @@ -64,10 +64,39 @@ class Bootstrap extends Bootstrap_Abstract
*/
public function _initRoute(Dispatcher $dispatcher)
{
$config = new Config\Ini(APPLICATION_PATH . '/configs/routes.ini');
if (isset($config->routes)) {
$dispatcher->getRouter()->addConfig($config->routes);
/* 根据域名的级别,选择对应的模块 */
$hostParts = explode('.', $dispatcher->getRequest()->getServer('HTTP_HOST', ''));
$level = count($hostParts) - 1;
$module = 'Index';
// 三级域名
if ($level === 3) {
switch (strtolower(strval($hostParts[0]))) {
case 'm':
case 'new': // 默认
$module = 'Index';
break;
case 'guang': // 逛
$module = 'Guang';
break;
case 'list': // 商品列表
$module = 'Product';
break;
default: // 其它(识别为品牌)
$module = 'Brand';
break;
}
}
$dispatcher->getRequest()->module = $module;
/* 根据对应模块的配置,添加相应的路由规则 */
$iniFile = APPLICATION_PATH . '/configs/routes.' . strtolower($module) . 'ini';
if (file_exists($iniFile)) {
$config = new Config\Ini($iniFile);
if (isset($config->routes)) {
$dispatcher->getRouter()->addConfig($config->routes);
}
}
}
/**
... ...