In my opinion, the correct way to add additional rules (for example with an application component) to already proccessed rules should be:
$additionalRules = array(...);
foreach ($additionalRules as $rule)
{
Yii::app()->urlManager->rules[] = $rule;
}
Yii::app()->urlManager->init();
In fact, I only have to do:
Yii::app()->urlManager->rules = $additionalRules;
Yii::app()->urlManager->init();
Because the (already proccessed) old rules are still available in CUrlManager::$_rules. This is irritating. Let’s say I have a bunch of default rules which are loaded always (through config). If I now want to drop the default rules and use the ones which are defined over an app componenent, how should I do that? It’s not possible to unset the private var $_rules.
Fix would be:
$this->_rules=array();
right before:
foreach($this->rules as $pattern=>$route)
$this->_rules[]=new CUrlRule($route,$pattern);
if(isset($cache))
$cache->set(self::CACHE_KEY,array($this->_rules,$hash));
in CUrlManager.
// Should I create a ticket or what you think about this?