How to access current controller object from component?


How would you access current controller object from Component/Object?

In my tests Yii::$app->controller returns null.

Should Component/Object be specifically initialised in order to access controller from it?


You should keep isolate components and controllers, to guarantee reusability.

Why should you call controller from component?

according to code, controller is set at Module:runAction() when app runs

you probably call it too early. if you kinda want to bind some stuff to controller, use events beforeAction or make your own. etc