Throw an expcetion in our Dispatcher if the controller is not an instance of Zend_Controller_Action_Interface

refs #5786
This commit is contained in:
Eric Lippmann 2015-08-17 13:38:16 +02:00
parent e26a7fd4d1
commit 06e879f078
1 changed files with 13 additions and 1 deletions

View File

@ -4,6 +4,9 @@
namespace Icinga\Web\Controller;
use Exception;
use Zend_Controller_Action;
use Zend_Controller_Action_Interface;
use Zend_Controller_Dispatcher_Exception;
use Zend_Controller_Dispatcher_Standard;
use Zend_Controller_Request_Abstract;
use Zend_Controller_Response_Abstract;
@ -21,7 +24,9 @@ class Dispatcher extends Zend_Controller_Dispatcher_Standard
* @param Zend_Controller_Request_Abstract $request
* @param Zend_Controller_Response_Abstract $response
*
* @throws Exception If dispatching the request fails
* @throws Zend_Controller_Dispatcher_Exception If the controller is not an instance of
* Zend_Controller_Action_Interface
* @throws Exception If dispatching the request fails
*/
public function dispatch(Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response)
{
@ -42,6 +47,13 @@ class Dispatcher extends Zend_Controller_Dispatcher_Standard
return;
}
$controller = new $controllerClass($request, $response, $this->getParams());
if (! $controller instanceof Zend_Controller_Action
&& ! $controller instanceof Zend_Controller_Action_Interface
) {
throw new Zend_Controller_Dispatcher_Exception(
'Controller "' . $controllerClass . '" is not an instance of Zend_Controller_Action_Interface'
);
}
$action = $this->getActionMethod($request);
$request->setDispatched(true);
// Buffer output by default