I have members that can be blocked, and when a member is blocked, I want to send them to the user errors page, how would I do this in the zend framework? I tried
throw new Zend_Controller_Dispatcher_Exception('Your message here');
but he doesn’t say “your message is here,” he says “page not found” when I do this.
here is my error controller.
<?php
class ErrorController extends Zend_Controller_Action
{
public function errorAction()
{
$errors = $this->_getParam('error_handler');
switch ($errors->type) {
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
$this->getResponse()->setHttpResponseCode(404);
$this->view->message = 'Page not found';
break;
$this->getResponse()->setHttpResponseCode(666);
$this->view->message = 'Blocked';
break;
default:
$this->getResponse()->setHttpResponseCode(500);
$this->view->message = 'Application error';
break;
}
if ($log = $this->getLog()) {
$log->crit($this->view->message, $errors->exception);
}
if ($this->getInvokeArg('displayExceptions') == true) {
$this->view->exception = $errors->exception;
}
$this->view->request = $errors->request;
}
public function getLog()
{
$bootstrap = $this->getInvokeArg('bootstrap');
if (!$bootstrap->hasPluginResource('Log')) {
return false;
}
$log = $bootstrap->getResource('Log');
return $log;
}
}
Here is the documentation, http://framework.zend.com/manual/en/zend.exception.using.html I don't understand: (
source
share