在哪里设置模块特定的全局变量以及如何设置


Where to set module specific global variables and how

我正在使用kohana 3.1构建一个比较大的应用程序。我试图设置模块范围的变量,如定义。它将是一些key =>值的数组。

举个例子,如果它是一个用户模块,我想设置可用的配置文件,如

$profiles = array(
  'user' => array('desc'=>'common user','access'=>'1'),
  'jonhdoe' => array('desc'=>'not logged user','access'=>0)
);

并在整个模块中使用$profiles,但不在外部使用。应该在init。php中设置吗?如果有,怎么做?

在你的模块类中使用受保护的属性

protected profiles = array();

在模块的某处:

$this->profiles = array(
  'user' => array('desc'=>'common user','access'=>'1'),
  'jonhdoe' => array('desc'=>'not logged user','access'=>0)
);