Hot answers tagged

1

You find the controller class in a request attribute: $controller = \Drupal::request()->attributes->get('_controller'); You need to instantiate the controller and run the code a second time. For not-so-easy logic it might be a better idea to refactor the code to a service which then caches the result for the second run, as @Hudri commented. Or take a ...


Only top voted, non community-wiki answers of a minimum length are eligible