setComponents() being ignored

Hi there,

I am trying to override the loginUrl for certain modules and it appears the setComponents is not working. In the module init function I have the following setting:




$this->setComponents(array(

	'user'=>array(

	         'loginUrl' =>array('auth/login'), 

		 'class' =>'WebSiteUser'

		   )

		)

	);  

		



For belt and braces I also created a new webuser class like this :





class WebSiteUser extends CWebUser

{

	public $loginUrl = array('auth/login');


}

I am currently using yii-1.1.8.r3324

Is there a prescribed way of doing this?

Thanks! ;)

this way you are creating a new component ‘user’ for the module in question.

to accomplish what you are trying (an user login for each module), keep doing this way and use the module’s user component to login

Hi Gustavo,

Thanks for the reply. Can you let me know where I can edit the user component of a module. The method I am trying now is being ignored and the user component settings from config/main.php is being used instead.

Thanks !

Each module has its own components. The way you are doing, you are creating a new component ‘user’ for your module

to override the application component user do the following


$component=Yii::createComponent(array(

//component details here

));

Yii::app()->setComponent('user',$component);

But I don’t think its a good idea override the application default component, a better way to do it is how I said, create a new user component for the module and use it instead

Hi Gustavo,

Thanks for the advice. Much appreciated! ;)

If you didn’t solve it yet, take a look at this wiki that explain how to do it