Yii createUrl在扩展的CBaseUrlRule类中无法正常工作
我创建了自己的类,它扩展了CBaseUrlRule来管理站点上的某些页面。结果类代码为Yii createUrl在扩展的CBaseUrlRule类中无法正常工作,yii,yii-url-manager,Yii,Yii Url Manager,我创建了自己的类,它扩展了CBaseUrlRule来管理站点上的某些页面。结果类代码为 class HotelUrlRule extends CBaseUrlRule { public function parseUrl($manager,$request,$pathInfo,$rawPathInfo) { if(isset($_GET['id'])) { if (($_GET['id'] != 0) && ($pathInfo == 'hotel'))
class HotelUrlRule extends CBaseUrlRule {
public function parseUrl($manager,$request,$pathInfo,$rawPathInfo) {
if(isset($_GET['id'])) {
if (($_GET['id'] != 0) && ($pathInfo == 'hotel')) {
return 'hotel/index';
}
}
return false;
}
public function createUrl($manager,$route,$params,$ampersand) {
if ($route == 'hotel/index') {
Yii::import('application.controllers.SearchController');
$searcher = new SearchController($this, NULL);
$hotelRaw = $searcher->actionGetHotelInformation($_GET['id']);
$hotelRaw = $hotelRaw['GetHotelInformationResult'];
$hotelName = $hotelRaw['Name'];
$hotelName = preg_replace('%(\s)%', '-', $hotelName);
return 'hotel/' . $hotelName;
}
return false;
}
}
parseUrl$\u GET['id']中的条件!=0&&$pathInfo=='hotel'返回'true',createUrl$route=='hotel/index'中的条件返回'false'。$route的Var_转储为“admin/auth”
为什么会这样?猜猜看