I'm using Kohana 3.2 with Controller_Template. Basically what I would like to do is to check the ACL of each action_method. If fail, load the access denied view and skip the rest of the action_method code; else continue loading.
I know I could use an if...else statement to do a simple boolean check (or even do a if(check_permission())return;
), but I hope there is a more elegant way of handling it with the least amount of extraneous code in the action_page()
... if possible, just check_permission();
. I'm okay with adding more code within function check_permission()
function check_permission() {
$this->template->content = View::factory('system/access_denied')
->bind('title', $title);
$title = 'Access Denied';
}
function action_page() {
check_permission();
$this->template->content = View::factory('page/index')
->bind('title', $title);
->bind('data', $data);
$title = 'Page loaded';
.
.
.
}
Perhaps there is some way specifically in kohana that can achieve this? Native php is fine too...