Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

View is still called on controller interrupt event

Hello! I have a basic Phalcon project. For personal reasons i don't want to use the ACL.

But whenever i want to INTERRUPT the execution of the controller (for example to use the redirect function from response) the layout is still called. This represents a problem as if the view uses a variable the script will return broken layout with 500 error.

In my case, the DashboardController have a function beforeExecuteRoute that executes $this->response->redirect('login'); and returns false if user is not logged. But as the Dashboard/index template uses a variable, instead of redirecting, i receive a 500 error and it logs on apache error log " PHP Fatal error: Call to a member function getAction() on a non-object in /srv/www/htdocs/var/cache/template/compiled/%%srv%%www%%htdocs%%app%%template%%account%%forgotpassword.volt.php "


So, am i using the view/events not in the right way ?


Try adding


before return false;


Thank you @Phalcon, that solved it and is cleaner than my first approach :)