Reputation: 5240
I've been reading CakePHP's 2.0 migration guide where it's stated that cakeError()
has been removed because it was used for exceptions. It's a really weird change IMHO because I used it to block access to unauthorized users or to trigger an error when the paginated items exceeded the total, and things like that.
And now what? Should I just throw a die()
or a redirect? I really want to let know the users that something was not found and Cake used to provie a stright way to do so... now it doesn't.
Any thoughts/hacks/workarounds about it? Thanks, happy holidays!
Upvotes: 9
Views: 6128
Reputation: 824
try this
if ($this->Session->read('Auth.User.role') == 'P' || $this->Session->read('Auth.User.role') == 'U') {
//die('you are not allowed to access this page');
//throw new ForbiddenException;
throw new NotFoundException('404 Error - Page not found');
}
Upvotes: 0
Reputation: 9964
You have to throw the corresponding exception, in your case the NotFoundException
:
throw new NotFoundException();
See also the chapter about exceptions in the cook book.
Upvotes: 13