Get module config settings or params

211 Views Asked by At

I'm using Yii 1, And am trying to get the module settings set in my config/main.php that look like this

'modules' => array (
                'products' => array(
                    'countries' => array('sg', 'th'),
                 )
),

This code works in my the non products controllers

Yii::app()->controller->getModule('Products')->countries;

But when i add into my custom URL class it doesn't. Here is part of my class

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)
    {
        .........
    }

    .........

}

On this, i get this error

Call to a member function getModule() on null 

and when i use this

Yii::app()->getModule('Products')->countries;

i get nothing, and no error

How do i fix this? Thanks

0

There are 0 best solutions below