Answer the question
In order to leave comments, you need to log in
How to execute a function in all controllers in yii2?
Hello.
It is necessary to run one method on each page of the application. This method will fire along with the BEFORE_ACTION event in each application controller. Seems like it needs a filter. But how to specify in the configuration that this filter is connected everywhere, so that you do not have to set the behaviors() method in each controller ?
Answer the question
In order to leave comments, you need to log in
As an option, all controller classes inherit from a custom class, and place the required method in this custom class, often the use of such a class will solve many problems
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question