Hi Everyone,
I have been trying to implement event reading this doc .
But unfortuantely I do not understand how use event. I have created a class in components folder as:
namespace app\components;
use yii\base\Component;
use yii\base\Event;
use yii\web\View;
class Foo extends Component{
const EVENT_HELLO = 'hello';
public function bar()
{
$this->trigger(self::EVENT_HELLO);
}
}
I do not understand where I should write the code of yii\base\Component::on() method. Shall I write yii\base\Component::on() method in controller or model. And how to acheve the output of events. Can you give me an example as I can understand the events quickly.
Thanks in advance