I’m building my first CakePHP 5 app and have run into what I’m sure is a very simple problem.
In Cake 4 I often call a method in one controller from another - I will typically set up a utility controller for various formatting tasks etc and then call it from other controllers.
To do this I just used (new UtilitiesController())->aMethod($args) which worked perfectly.
In Cake 5 I can’t get this to work, looking at the error message I got when I first tried to use this it seems I need to pass the request in as an argument, so I tried
Which seemed to access the third party controller OK, except the function did not work correctly, and when I tested it by calling the same function directly from the view layer it worked fine, so I think there is something wrong with how I am trying to access the 3rd party method.