Where to set module specific global variables and how
I'm building a somewhat large application using kohana 3.1. I'm trying to set module-wide variables, like definitions. It will be some arrays with key => values.
To give an example, if it was a user module I would like to set the avail开发者_开发技巧able profiles like
$profiles = array(
'user' => array('desc'=>'common user','access'=>'1'),
'jonhdoe' => array('desc'=>'not logged user','access'=>0)
);
and use the $profiles all over my module but not on the outside. Should I set it in init.php? If so, how?
Use protected properties in your module class.
protected profiles = array();
somewhere in the module:
$this->profiles = array(
'user' => array('desc'=>'common user','access'=>'1'),
'jonhdoe' => array('desc'=>'not logged user','access'=>0)
);
And you can access this array ONLY from module class or its child-classes.
精彩评论