Has anyone ever needed to bind an ActiveRecord event handler in a way that it only triggers on certain scenarios?
In an ideal world the ActiveRecord on()
method would also take a $scenarios parameter and trigger the handler only if the ActiveRecord is using that scenario at the time the event occurs. But since that is not the case I am looking for a clean, reliable way to implement this type of functionality.
Edit: This needs to work with any event, including built-in events triggered by the Yii framework (eg. ActiveRecord::EVENT_AFTER_INSERT
).