I just don’t know why I cannot call a method that I have added to Controller.php from a view, It’s so simple, but I guess I’m missing something, I get this error: SiteController and its behaviors do not have a method or closure named “createMultilanguageReturnUrl”.
protected/components/Controller.php
class Controller extends CController
{
public function __construct($id,$module=null){
parent::__construct($id,$module);
Yii::app()->language = (isset($_GET['lang']))?$_GET['lang']:Yii::app()->language;
}
public function createMultilanguageReturnUrl($lang='en'){
$arr = array('lang'=>$lang);
if (count($_GET)>0){
$arr = $_GET;
$arr['lang']= $lang;
}
return $this->createUrl('', $arr);
}
}
The curious thing is that if I create a new controller xyz extending from CController and then I extend SiteController from xyz, then I can reach that function in xyz controller.
You rock!!! I just don’t know why but… I’m using modules, so in each module there is a Controller.php in components folder, I have deleted all thoses Controller.php files, so every module controller extends from proteted/components/Controller.php and it WORKS! I wonder why, because I thought a module works as a independent application…
Ok, so in your opinion, what would be a good practice if I want to call a function visible for all controllers in my app?
Thanks for your comments ORey! Once again! I definetely will buy you a beer