Setting unknown property modle::on upon attaching events

I’m trying to attach few events to my model object, but it is throwing an error.


$newAppt = new \app\models\ApptSchedule;

$newAppt->on = [self::EVENT_APPT_CREATED,'\backend\controllers\NotifyController', 'textCaller'];

$newAppt->on = [self::EVENT_APPT_CREATED,'\backend\controllers\NotifyController', 'notifyAdmins'];

$newAppt->on = [self::EVENT_APPT_CREATED,'\backend\controllers\NotifyController', 'NotifyDoctor'];

I noticed that ActiveRecord Model is extended from yii\base\Component so ‘on’ property should be available for model object. Am I missing anything obvious? Please help.

‘on’ is a method, but I was trying to use it like a property. This code works!.


$newAppt->on(self::EVENT_APPT_CREATED,['\backend\controllers\NotifyController', 'textCaller']);

$newAppt->on(self::EVENT_APPT_CREATED, ['\backend\controllers\NotifyController', 'notifyAdmins']);

$newAppt->on(self::EVENT_APPT_CREATED, ['\backend\controllers\NotifyController', 'NotifyDoctor']);