parent
5923622fb8
commit
b58ec5f445
|
@ -30,6 +30,7 @@
|
|||
namespace Icinga\Application\Modules;
|
||||
|
||||
use Exception;
|
||||
use Zend_Controller_Router_Route_Abstract;
|
||||
use Zend_Controller_Router_Route as Route;
|
||||
use Icinga\Application\ApplicationBootstrap;
|
||||
use Icinga\Application\Config;
|
||||
|
@ -150,6 +151,16 @@ class Module
|
|||
*/
|
||||
private $app;
|
||||
|
||||
|
||||
/**
|
||||
* Routes to add to the route chain
|
||||
*
|
||||
* @var array Array of name-route pairs
|
||||
*
|
||||
* @see addRoute()
|
||||
*/
|
||||
protected $routes = array();
|
||||
|
||||
/**
|
||||
* Create a new module object
|
||||
*
|
||||
|
@ -594,13 +605,17 @@ class Module
|
|||
}
|
||||
|
||||
/**
|
||||
* Register routes for web access
|
||||
* Add routes for static content and any route added via addRoute() to the route chain
|
||||
*
|
||||
* @return self
|
||||
* @return self
|
||||
* @see addRoute()
|
||||
*/
|
||||
protected function registerRoutes()
|
||||
{
|
||||
$router = $this->app->getFrontController()->getRouter();
|
||||
foreach ($this->routes as $name => $route) {
|
||||
$router->addRoute($name, $route);
|
||||
}
|
||||
$router->addRoute(
|
||||
$this->name . '_jsprovider',
|
||||
new Route(
|
||||
|
@ -687,4 +702,19 @@ class Module
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a route which will be added to the route chain
|
||||
*
|
||||
* @param string $name Name of the route
|
||||
* @param Zend_Controller_Router_Route_Abstract $route Instance of the route
|
||||
*
|
||||
* @return self
|
||||
* @see registerRoutes()
|
||||
*/
|
||||
protected function addRoute($name, Zend_Controller_Router_Route_Abstract $route)
|
||||
{
|
||||
$this->routes[$name] = $route;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue