开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜