diff --git a/docs/guide/concept-di-container.md b/docs/guide/concept-di-container.md index 4a87a9c3d44..fb312e553c4 100644 --- a/docs/guide/concept-di-container.md +++ b/docs/guide/concept-di-container.md @@ -396,6 +396,18 @@ class HotelController extends Controller } ``` +Note that not all core code supports DI due to performance concerns. You can add support if needed by overriding +the method responsible for instantiating the class and making sure it uses [[Yii::createObject()]]. + +For example, you can add DI support to [[yii\db\ActiveRecord]] models by overriding the `instantiate()` method: + +```php +public static function instantiate($row) +{ + return Yii::createObject(static::class); +} +``` + Advanced Practical Usage ---------------