php - 获取模块配置设置或参数
问题描述
我正在使用 Yii 1,并试图让我的模块设置config/main.php
看起来像这样
'modules' => array (
'products' => array(
'countries' => array('sg', 'th'),
)
),
此代码适用于我的非products
控制器
Yii::app()->controller->getModule('Products')->countries;
但是当我添加到我的自定义 URL 类中时,它不会。这是我课的一部分
class RegionUrlRule extends CBaseUrlRule
{
public $connectionID = 'db';
private $countryArray;
public function __construct() {
//get list of allowed countries
$this->countryArray = Yii::app()->controller->getModule('Products')->countries;
}
public function createUrl($manager,$route,$params,$ampersand)
{
.........
}
.........
}
对此,我收到此错误
Call to a member function getModule() on null
当我使用这个
Yii::app()->getModule('Products')->countries;
我什么也没得到,也没有错误
我该如何解决?谢谢
解决方案
推荐阅读
- android - UPNP android 错误代码 710 不支持搜索模式
- php - OctoberCMS 制作属于守护进程的文件夹和文件
- wordpress - 具有 Swift 性能的 WP 站点加载未使用的图像
- python - 'DataFrame' 对象没有属性 '_check_fit_params'
- spring-boot - 在 Spring-Boot 中启用 CORS 时是否仍需要基本身份验证?
- javascript - 当我尝试使用 JS/JQuery 在新窗口中写入时出现问题
- sql - SQL 显示前一个值,直到给定值改变
- automation - 在自动化项目中,哪种是保存和使用海量数据进行测试的理想方式?
- javascript - 状态没有在reducer中更新在react native
- flutter - 颤振中的真实身高?