Curlmanager Addcacherules

I am creating an application where there are UserGroups and Users.

The problem is that every UserGroup has a different alias that they like in the Url (but the application is all the same).

Example:

One might call Enemies while another Baddies.

I am currently doing this:


Yii::createWebApplication($config);

Yii::app()->urlManager->addRules(UserGroup::getUrls());

Yii::app()->run();

and I don’t set any rules in the $config.

I would like to take advantage of the Url Caching, but using addRules only addeds it to the $_rules[] and doesn’t cache it.

At first, I was thinking to change the private to protected and extending the class and overriding processRules(). But I wanted to find a more "permanent" solution for people to use in the future (without adding another request to make private variables protected).

doing this would require additional cache parameters.

I would like to see something like:


private $_cacheKey=self::CACHE_KEY;

Then here is the function I would for addCacheRules:


public function addCacheRules($rules,$cache='',$append=true)

{

	$this->_cacheKey.='.'.$cache;

	

	if ($append)

	{

		$this->rules = array_merge($rules,$this->rules);

	}

	else

	{

		$this->rules = array_merge($this->rules,$rules);

	}

}

and then processRules would look as follow (only changed self::CACHE_KEY -> $this->_cacheKey ):


protected function processRules()

{

	if(empty($this->rules) || $this->getUrlFormat()===self::GET_FORMAT)

		return;

	if($this->cacheID!==false && ($cache=Yii::app()->getComponent($this->cacheID))!==null)

	{

		$hash=md5(serialize($this->rules));

		if(($data=$cache->get($this->_cacheKey))!==false && isset($data[1]) && $data[1]===$hash)

		{

			$this->_rules=$data[0];

			return;

		}

	}

	foreach($this->rules as $pattern=>$route)

		$this->_rules[]=$this->createUrlRule($route,$pattern);

	if(isset($cache))

		$cache->set($this->_cacheKey,array($this->_rules,$hash));

}

maybe there is a better way that I am missing?