From 902c00e836fad029ee2279f1712e31abf382779a Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 19 May 2015 17:29:34 +0200 Subject: [PATCH] lib: Introduce Controller::httpNotFound() Many actions require loading specific objects from database or any other storage. If the object isn't found, Controller::httpNotFound($message) should be used for immediately returning w/ HTTP 404. --- library/Icinga/Web/Controller.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/library/Icinga/Web/Controller.php b/library/Icinga/Web/Controller.php index 9acf17469..0975d4c13 100644 --- a/library/Icinga/Web/Controller.php +++ b/library/Icinga/Web/Controller.php @@ -3,6 +3,7 @@ namespace Icinga\Web; +use Zend_Controller_Action_Exception; use Icinga\Data\Sortable; use Icinga\Data\QueryInterface; use Icinga\Web\Controller\ModuleActionController; @@ -49,6 +50,18 @@ class Controller extends ModuleActionController } } + /** + * Immediately respond w/ HTTP 404 + * + * @param $message + * + * @throws Zend_Controller_Action_Exception + */ + public function httpNotFound($message) + { + throw new Zend_Controller_Action_Exception($message, 404); + } + /** * Create a SortBox widget and apply its sort rules on the given query *