Create a new Instance of a controller

I have a method in a class A (classic Php class and I need to have access to the request (with some identity attribute in cakeDC/Users plugin)…how can I code something that is RequestAware ? I can pass it as parameter, but I would like to have something that inject or get the session or request .


You might get away with

$request = Router::getRequest();

But this can make things really hard to test.

You could also look into dependency injection which should be much more testable.

thanks, it works, I will encapsulate it into a method that I can moke :slight_smile: