phant
(J Andrijankinas)
1
Hello everybody,
I am in an urgent need to solve one problem.
In /protected directory I created file action.php. In that file I have calculated a variable and I need this variable to put in my Yii application.
How is it possible to make this variable accessible to Yii::app()?
For example I need to use this variable in /protected/components/ApplicationBehavior.php file.
zaccaria
(Matteo Falsitta)
2
You can create a class in component with a static method:
class myVar
{
public static function var()
{
[your code here]
return $variable;
}
}
Now, whereever in your code, you can do
myVar::var()
and obtain the value you need.
phant
(J Andrijankinas)
3
Thank you, do I need to put anything in config?
zaccaria
(Matteo Falsitta)
4
No, usually in config there is something like
'import'=>array(
'application.models.*',
'application.components.*',
),
That means that everithing that stays in components (and models) is authomatically included