public function execute(string
$method, ...
$params) { if (!
method_exists($this->controller,
$method) || !
is_callable([$this->controller,
$method])) { throw new InvalidArgumentException('Method does not exist or is not callable in controller: ' .
$method);
} // The URL helper is always loaded by the system
// so ensure it's available.
helper('url'
);
$result =
(new ControllerResponse()) ->
setRequest($this->request
) ->
setResponse($this->response
);
$response = null;
try { ob_start();
$response =
$this->controller->
{$method}(...
$params);
} catch (Throwable
$e) { $code =
$e->
getCode();