Arth
Arth

Reputation: 13110

Yii2 extend or replace core class

I'd like to either extend or replace yii\db\ActiveQuery with my own class and have the entire application use it.

This is to bring in the @alias functionality referenced by CedricYii at the bottom of this GitHub issue.

Due to the private nature of some of the changed functions, I'll probably have to replace it.

Is this possible? Or will I have to fork the repository?

Upvotes: 3

Views: 880

Answers (1)

SilverFire
SilverFire

Reputation: 1592

Use Dependency Injection Container for this.

Write down in your application bootstrap code:

Yii::$container->set('yii\db\ActiveQuery', 'app\components\ActiveQuery');

Upvotes: 5

Related Questions