Getmodule

Hello everybody,

I found out the if you are in the init function of a module and you call Yii::app()->getModule(‘moduleName’)->property; the application will enter into an infinite loop.

for example:





class moduleName extends CWebModule

{

   public property = 1;

   public function init()

    {

 		Yii::app()->getModule('moduleName')->property; // infinite loop; 

   }

}



So how can I find out the property value?





 $this->property; 




is not good, because I what tho be able to use the code in other parts of the application;

for example:





class Component{

	public static function moduleProperty(){

		return Yii::app()->getModule('moduleName')->property;

        } 


}







class moduleName extends CWebModule

{

   public property = 1;


   public function init()

   {

      Component::moduleProperty();

   }

}



haha[size="2"], I fount the solution:[/size]




class Component{

        public static function moduleProperty($module){

                return $module->property;

        } 


}







class moduleName extends CWebModule

{

   public property = 1;


   public function init()

   {

      Component::moduleProperty($this);

   }

}



Well in the lates yii version: yii-1.1.13.e9e4a0 the infinit loop still persist even with the above changes…

Is there any way to aviod this infinit loop? Maybe it is a bug or something…

Anyone???

What happens of you just do $this->property? Can you just pass that variable directly to your component?

Basically in a module init function, I can not access $this->property because; the script just seems to enter into an infinite loop…

Does that occur if you try it set config values for your module? I’ve got some modules that I add in submodules to and things work fine. The syntax is like this:




$this->modules = array(

    ... config information for other modules here

);



I know that code works, as it’s running in production on a system that launched yesterday.

Let me know. Also, you don’t happen to be overriding your __get / __set methods, so you?

Hi all,

Is the getModule mechanism, can acquired the nested module?

Thanx in advance