I learn about events from yii2 doc.
I know how it works, but i don't know where to use it and how to use it in my development.There is example of send email notification but i want a solid example which clear the idea where to use and how to use it .
MY code is below in model i write
const EVENT_NEW_USER = 'new-user';
public function sendMailto($event){
$this->sendMail(arguments);
// you code
}
in controller:
use yii\base\Component;
use yii\base\Event;
public function someaction (){
$model->on(SignUpForm::EVENT_NEW_USER, [$model,'sendMailto'],['auth'=>$model_auth,'user_details'=>$user_details]);
$model->trigger(SignUpForm::EVENT_NEW_USER);
}