I’m trying to get the components that I defined within a module, but for some reason it only returns a empty array.
I use the code below to print_r the components array just to debug the code.
class AdminModule extends CWebModule
{
public function init()
{
// this method is called when the module is being created
// you may place code here to customize the module or the application
// import the module-level models and components
$this->setImport(array(
'admin.models.*',
'admin.components.*',
));
// this sets default settings for admin module
$this->setComponents(array(
'errorHandler' => array(// set error handler specificly for this module
'errorAction' => "{$this->id}/default/error"
),
'user' => array( // set user and authentication options
'loginUrl' => Yii::app()->createUrl("{$this->id}/default/login"),
'stateKeyPrefix' => "_{$this->id}",
),
));
// set all the features for a WebModule automaticly by init functionality
//parent::init();
}
public function beforeControllerAction($controller, $action)
{
print_r($this->getComponents());//<- here I'm trying to output Components that i defined
if(parent::beforeControllerAction($controller, $action))
{
// this method is called before any module controller action is performed
// you may place customized code here
return true;
}
else
return false;
}
}