Welcome Guest, Not a member yet? Register   Sign In
AdminController - how to redirect in __construct or initController function?
#2

(This post was last modified: 01-21-2021, 08:14 PM by iRedds.)

Even if there is a return operator in the class constructor, it will not return anything.
No return is expected when the initController method is called.

In my humble opinion you need to use filters. If you cannot use the code that you use in the controller in filters, then your application has design problems.
But if you really need to redirect from the class constructor, you can throw an exception

PHP Code:
throw new RedirectException('urlToRedirect'); 
Reply


Messages In This Thread
RE: AdminController - how to redirect in __construct or initController function? - by iRedds - 01-21-2021, 08:13 PM



Theme © iAndrew 2016 - Forum software by © MyBB