G
G
Greg Popov2016-11-02 18:14:06
Yii
Greg Popov, 2016-11-02 18:14:06

How to bulk assign behavior to all models in Yii2?

Actually the whole question in the topic. There is an idea to make your own model, and inherit from it, but maybe there is a more elegant way?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2016-11-03
@webinar

Behavior in yii is a very flexible thing, it's easy to screw it to the model, you can customize it, etc. If it's a question of laziness, then you can rewrite gii templates, add conditions so that it generates models with already connected behavior. I did this for behaviors that load images and implement statuses and other commonly used methods.
The general model will be an analogue of behavior, with a truncated functionality. The behavior is a more flexible thing, it can be configured, disabled, etc., I don’t see the point.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question