Reputation: 11829
I need a way to decrypt encrypted URL request parameters into the original Yii controller/action
path. Example:
From: http://www.site.com/feh923rfj932
(encrypted)
To: http://www.site.com/api/view/1
(decrypted)
Is there some CUrlManager router callback I can use to implement a decrypt method?
Upvotes: 0
Views: 4914
Reputation: 15600
Yes, Yii provides an easy way to implement your own URL logic using Custom Url Classes "callbacks".
Basically, you will declare a new rule that points to your new decoder/encoder class:
'rules' => array(
'' => 'site/index', // normal URL rules
array( // your custom URL handler
'class' => 'application.components.CustomUrlRule',
),
),
Your URL class will look something like this:
class CustomUrlRule extends CBaseUrlRule {
public function createUrl($manager,$route,$params,$ampersand) {
return your_encrypt_method($route);
}
public function parseUrl($manager,$request,$pathInfo,$rawPathInfo) {
return your_decrypt_method($pathInfo);
}
}
Upvotes: 4