Loss Of Beforefind And Behaviors For Activequery

I see that the new set up for ActiveRecord and ActiveQuery makes it difficult for ActiveQuery to trigger events on the ActiveRecord model, but I’m wondering if anyone has any ideas how to get the beforeFind event back and add ActiveRecord specific behaviors to ActiveQuery. I use beforeFind in my Yii1 ACL behavior to add in joins.

-Jacob

For now, I’ve overloaded ActiveRecord and ActiveQuery. I created a static function in ActiveRecord called queryBehaviors. On ActiveRecord::createQuery, I have it attach the behaviors in ActiveRecord::queryBehaviors before returning the object. I then overloaded ActiveQuery::createCommand to trigger a beforeQuery event before returning parent::createCommand. A tad messy, but it gets the job done. This will also be useful because I have scoping functions in some of my ActiveRecord behaviors.

-Jacob