T
T
tincap2015-07-08 18:11:22
Yii
tincap, 2015-07-08 18:11:22

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

1 answer(s)
E
Evgeny Bukharev, 2015-07-08
@tincap

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 question

Ask a Question

731 491 924 answers to any question