Possible issue with router->controllerName() |
Hi there,
In a filter I'm doing the following: Code: public function before(RequestInterface $request, $arguments = null) This works fine until I turn on "hot reload" whereby I get the following error in the log file: Code: CRITICAL - 2024-12-11 12:54:32 --> TypeError: explode(): Argument #2 ($string) must be of type string, Closure given It's not critical as I rarely use hot reload, however it could also be me doing something wrong.
Nobody has picked up on this so I have investigated further.
I have noticed that my "before" filter is called twice on an initial page load when hot load is enabled. I don't know why this is. On the one call the controllerName() function returns the correct string, but on the other call it returns a Closure object which is what is breaking my code. I've modified my code so that my "before" filter simply returns if this condition is false: PHP Code: $controllerName = $router->controllerName(); This seems to have fixed the problem without compromising what the filter is doing. |
Welcome Guest, Not a member yet? Register Sign In |