I am trying to register an event from within a module. So, I added this couple of lines in the init function of my module class (protected/modules/points/PointsModule.php
).
class PointsModule extends CWebModule {
public function init() {
...
// Attach the "User Register" event
Yii::app()->user->onUserRegister = array($this, "addPointsForRegistration");
die('init');
}
...
}
I only see the result of the die('init')
when I use the module controller. Any other page of my application won't do anything.
I import the file in config/main.php
file
'import'=>array(
'application.modules.points.*',
),
I don't understand what I am doing wrong here. The file seems to be not loaded at all if I am not using the module's controller.
Is there a way to load a module class (or another component) at each page load in yii? Is there a cleaner way to register an event from inside a module?