Introduce a constant for the controller namespace

refs #5786
This commit is contained in:
Eric Lippmann 2015-08-17 13:43:34 +02:00
parent 06e879f078
commit 7252f3237a
2 changed files with 11 additions and 3 deletions

View File

@ -307,7 +307,7 @@ class Web extends EmbeddedWeb
$this $this
->getLoader() ->getLoader()
->registerNamespace( ->registerNamespace(
'Icinga\\Controllers', 'Icinga\\' . Dispatcher::CONTROLLER_NAMESPACE,
$this->getApplicationDir('controllers') $this->getApplicationDir('controllers')
) )
->registerNamespace( ->registerNamespace(

View File

@ -18,6 +18,13 @@ use Zend_Controller_Response_Abstract;
*/ */
class Dispatcher extends Zend_Controller_Dispatcher_Standard class Dispatcher extends Zend_Controller_Dispatcher_Standard
{ {
/**
* Controller namespace
*
* @var string
*/
const CONTROLLER_NAMESPACE = 'Controller';
/** /**
* Dispatch request to a controller and action * Dispatch request to a controller and action
* *
@ -38,9 +45,10 @@ class Dispatcher extends Zend_Controller_Dispatcher_Standard
} }
$controllerName = ucfirst($controllerName) . 'Controller'; $controllerName = ucfirst($controllerName) . 'Controller';
if ($this->_defaultModule === $this->_curModule) { if ($this->_defaultModule === $this->_curModule) {
$controllerClass = 'Icinga\\Controllers\\' . $controllerName; $controllerClass = 'Icinga\\' . self::CONTROLLER_NAMESPACE . '\\' . $controllerName;
} else { } else {
$controllerClass = 'Icinga\\Module\\' . $this->_curModule . '\\Controllers\\' . $controllerName; $controllerClass = 'Icinga\\Module\\' . $this->_curModule . '\\' . self::CONTROLLER_NAMESPACE . '\\'
. $controllerName;
} }
if (! class_exists($controllerClass)) { if (! class_exists($controllerClass)) {
parent::dispatch($request, $response); parent::dispatch($request, $response);