Yii trigger component event from controller action

728 Views Asked by At

I'm trying to create a method where I can trigger an event from a controller action (sending parameters with it), and have multiple components (in the same, or in another module) to listen that trigger and execute some random code (maybe some sanitised string or something)..

Is there a way to create such system with Yii Events? Or i'll need to work around something else?

Thanks

1

There are 1 best solutions below

0
On

Sure,

Yii has a nice event system using CEvent. Have a look at Events explained tutorial.

You can combine it with yii Behaviors, here's another good tutorial if you are interested in Behaviors & Events.

Behaviors are a way of adding methods to a Class without php limitations of class extending since you can attach several behaviors to a same class.