$app->on(KernelEvents::CONTROLLER, function (FilterControllerEvent $event) use ($app) {
$c = $event->getController();
/** @var BaseController $controller */
$controller = $c[0];
if ($controller instanceof BaseController) {
$controller->injectApp($app);
}
});
abstract class BaseController
{
protected $app;
public function injectApp(Application $app)
{
$this->app = $app;
return $this;
}
}