I am currently facing one problem about accessing the static array.
The case is that I have sub-modules. Each components directory in sub-modules has Redirector.php in which I am defining the Redirector class.Every Redirector class has $array.
Now the problem is -
I have one class in protected/component and there I want to access $array element of particular module.
Maybe you could use a global Redirector class and use that for all modules?
class Redirect
{
public static $array = array();
}
Then in your Module file:
class MyModule extends CWebModule
{
public function init()
{
Redirector::$array['MyModule']['data'] = array();
}
}
But init() in MyModule is only executed when you access the module. So if you need data from all modules (even if they are not initialized yet), you have to load the module first.
Can you explain more? So we could maybe find a better solution.
Thank you Y!! and Onman for your valuable responces.
I got one solution. But I wanted to know whether it is good or not.
Actually I was trying to write a generic function in protected/components. And this function needs to get the value from Redirector.php of any sub-module depending on the situation.
So I was needed to have some reference to Redirector class (defined in Redirector.php) of any module in a class defined in protected/components.
To solve this problem
I defined getValue() function in every module class. This function will return the values from Redirector class of respected module.
To access the value in protected/components I used