Prevent Controller from executing
codeigniter, php
Solution
You have to let the controller execute in order to let the requested URI load.
After you check the ACL in `MY_Controller` and if it is not permitted, you can load the `denied` view there, but you need to do one more thing before you exit.
$this->load->view('denied');
$this->output->_display();
exit();
Problem
I have an acl that is running in MY_Controller. If permission is denied, then at the moment, I just do a `redirect('denied')` - this is a very basic controller that loads a very basic view saying 'Permission denied'. However, what I would like to do instead, is still load the originally requested uri, but load the 'denied' view instead of the default view. I can do this in MY_Controller, and the denied view loads fine. However, this does not stop the original controller/method from executing as well, so I get both views loaded. I also tried putting an `exit;` statement in MY_Controller after loading the denied view, but this is not workable because then the output does not fire in CI. Is it perhaps possible to do this via a pre_constructor_controller hook? I couldn't figure out a way to prevent the controller from executing...