Welcome Guest, Not a member yet? Register   Sign In
Accessing controller and function name from hook
#1

[eluser]zackwragg[/eluser]
Hi,

I have just got Zend_ACL working and hooked to the front controller of my application. What I would like to do is have it check which controller and function a user is trying to load and decide if they have access. If they do, then load the controller. If not, redirect them to an error page. In this scenario, the controller would be my ACL resource and the function would the ACL privilege.

Now, my question is, is there an easy way to access the controller name and function name of the controller and function that the front controller is trying to load. At the moment I have doing this:

Code:
$resource = $this->CI->uri->segment(1);
$privilege = $this->CI->uri->segment(2);

However, if the user is trying to load www.example.com/ (i.e. with no query string) then this wouldn't work. I could easily put something like this in here to combat this problem:

Code:
if( $resource === null )
{
    $resource = 'default_resource';
}

I was just wondering if there is a specific way to access those names from the CI instance that would be a bit nicer.

In case it is relevant, I have my hook on the post_controller_constructor hook.

Any help is greatly appreciated.


Messages In This Thread
Accessing controller and function name from hook - by El Forum - 12-01-2008, 05:56 AM
Accessing controller and function name from hook - by El Forum - 12-01-2008, 10:06 AM
Accessing controller and function name from hook - by El Forum - 12-01-2008, 10:07 AM
Accessing controller and function name from hook - by El Forum - 12-01-2008, 10:10 AM



Theme © iAndrew 2016 - Forum software by © MyBB