In Yii2, it is possible to define interfaces in the constructor parameters, and the necessary implementations will be included there, defined via Yii :: $ container-> set ();
For example, in the authorization controller, I do this
public function __construct($id, $module, IAuthModelBuilder $modelBuilder, IAuthorizator $auth){} All implementations are defined in a separate file and loaded directly into the config.
Now I need, depending on what is passed in the request, to change the implementation of the IAuthorizator
In the config, you can set the 'on beforeRequest' event, but it is still not clear what controller and action is.
beforeAction is also not suitable, because in this place the controller has already been created and transferred to it.
How to be? Where is the place where the controller has not been created yet, but the url is already recognized?