MEM
MEM

Reputation: 31307

Zend Application - a 404 error instead of Zend_Acl_Exception - how?

At the present, when I type a wrong address I get the following:

exception 'Zend_Acl_Exception' with message 'Resource 'default_asda' not found' in /home/alkimi/www/ ...

I would like to, instead of this, display a costumized 404.

How can we configure the framework for doing so?

Thanks a lot, MEM

Upvotes: 0

Views: 619

Answers (2)

krinn
krinn

Reputation: 892

You can check if action and controller exists (is dispatchable) before checking permissions:

$front = Zend_Controller_Front::getInstance();
if (!$front->getDispatcher()->isDispatchable($request)) {
    throw new Zend_Exception('Page not found', 404);
    return false;
}

Upvotes: 0

Phil
Phil

Reputation: 164730

You get that exception when you attempt to query your ACL for a non-existant resource. You should check your ACL for the resource before calling isAllowed, eg

if (!$acl->has($resource)) {
    // do something that triggers or leads to a 404
}

Upvotes: 2

Related Questions