Web/controllers: use own Request/Response objects
* introduces Icinga\Web\Response * uses ModuleActionController where necessary * no module translationDomain voodoo in base ActionController
This commit is contained in:
parent
ef5e1b54fd
commit
b7fc0b67a8
|
@ -37,6 +37,7 @@ use Icinga\Exception\ConfigurationError;
|
||||||
use Icinga\Exception\NotReadableError;
|
use Icinga\Exception\NotReadableError;
|
||||||
use Icinga\Logger\Logger;
|
use Icinga\Logger\Logger;
|
||||||
use Icinga\Web\Request;
|
use Icinga\Web\Request;
|
||||||
|
use Icinga\Web\Response;
|
||||||
use Icinga\Web\View;
|
use Icinga\Web\View;
|
||||||
use Icinga\Web\Session\Session as BaseSession;
|
use Icinga\Web\Session\Session as BaseSession;
|
||||||
use Icinga\Web\Session;
|
use Icinga\Web\Session;
|
||||||
|
@ -48,7 +49,7 @@ use Exception;
|
||||||
use Zend_Layout;
|
use Zend_Layout;
|
||||||
use Zend_Paginator;
|
use Zend_Paginator;
|
||||||
use Zend_View_Helper_PaginationControl;
|
use Zend_View_Helper_PaginationControl;
|
||||||
use Zend_Controller_Action_HelperBroker;
|
use Zend_Controller_Action_HelperBroker as ActionHelperBroker;
|
||||||
use Zend_Controller_Router_Route;
|
use Zend_Controller_Router_Route;
|
||||||
use Zend_Controller_Front;
|
use Zend_Controller_Front;
|
||||||
|
|
||||||
|
@ -177,7 +178,7 @@ class Web extends ApplicationBootstrap
|
||||||
*/
|
*/
|
||||||
public function dispatch()
|
public function dispatch()
|
||||||
{
|
{
|
||||||
$this->frontController->dispatch();
|
$this->frontController->dispatch(new Request(), new Response());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -274,7 +275,7 @@ class Web extends ApplicationBootstrap
|
||||||
private function setupViewRenderer()
|
private function setupViewRenderer()
|
||||||
{
|
{
|
||||||
/** @var \Zend_Controller_Action_Helper_ViewRenderer $view */
|
/** @var \Zend_Controller_Action_Helper_ViewRenderer $view */
|
||||||
$view = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
|
$view = ActionHelperBroker::getStaticHelper('viewRenderer');
|
||||||
$view->setView(new View());
|
$view->setView(new View());
|
||||||
|
|
||||||
$view->view->addHelperPath($this->getApplicationDir('/views/helpers'));
|
$view->view->addHelperPath($this->getApplicationDir('/views/helpers'));
|
||||||
|
|
|
@ -31,10 +31,6 @@
|
||||||
namespace Icinga\Web\Controller;
|
namespace Icinga\Web\Controller;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Zend_Controller_Action;
|
|
||||||
use Zend_Controller_Request_Abstract;
|
|
||||||
use Zend_Controller_Response_Abstract;
|
|
||||||
use Zend_Controller_Action_HelperBroker;
|
|
||||||
use Icinga\Authentication\Manager as AuthManager;
|
use Icinga\Authentication\Manager as AuthManager;
|
||||||
use Icinga\Application\Benchmark;
|
use Icinga\Application\Benchmark;
|
||||||
use Icinga\Application\Config;
|
use Icinga\Application\Config;
|
||||||
|
@ -49,6 +45,10 @@ use Icinga\Web\Session;
|
||||||
use Icinga\Web\UrlParams;
|
use Icinga\Web\UrlParams;
|
||||||
use Icinga\Session\SessionNamespace;
|
use Icinga\Session\SessionNamespace;
|
||||||
use Icinga\Exception\NotReadableError;
|
use Icinga\Exception\NotReadableError;
|
||||||
|
use Zend_Controller_Action;
|
||||||
|
use Zend_Controller_Action_HelperBroker as ActionHelperBroker;
|
||||||
|
use Zend_Controller_Request_Abstract as Request;
|
||||||
|
use Zend_Controller_Response_Abstract as Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for all core action controllers
|
* Base class for all core action controllers
|
||||||
|
@ -93,13 +93,13 @@ class ActionController extends Zend_Controller_Action
|
||||||
* The constructor starts benchmarking, loads the configuration and sets
|
* The constructor starts benchmarking, loads the configuration and sets
|
||||||
* other useful controller properties
|
* other useful controller properties
|
||||||
*
|
*
|
||||||
* @param Zend_Controller_Request_Abstract $request
|
* @param Request $request
|
||||||
* @param Zend_Controller_Response_Abstract $response
|
* @param Response $response
|
||||||
* @param array $invokeArgs Any additional invocation arguments
|
* @param array $invokeArgs Any additional invocation arguments
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
Zend_Controller_Request_Abstract $request,
|
Request $request,
|
||||||
Zend_Controller_Response_Abstract $response,
|
Response $response,
|
||||||
array $invokeArgs = array()
|
array $invokeArgs = array()
|
||||||
) {
|
) {
|
||||||
$this->params = UrlParams::fromQueryString();
|
$this->params = UrlParams::fromQueryString();
|
||||||
|
@ -107,12 +107,10 @@ class ActionController extends Zend_Controller_Action
|
||||||
$this->setRequest($request)
|
$this->setRequest($request)
|
||||||
->setResponse($response)
|
->setResponse($response)
|
||||||
->_setInvokeArgs($invokeArgs);
|
->_setInvokeArgs($invokeArgs);
|
||||||
$this->_helper = new Zend_Controller_Action_HelperBroker($this);
|
$this->_helper = new ActionHelperBroker($this);
|
||||||
$this->_helper->addPath('../application/controllers/helpers');
|
|
||||||
$this->handlerBrowserWindows();
|
|
||||||
|
|
||||||
$module = $request->getModuleName();
|
$this->handlerBrowserWindows();
|
||||||
$this->view->translationDomain = $module === 'default' ? 'icinga' : $module;
|
$this->view->translationDomain = 'icinga';
|
||||||
|
|
||||||
if ($this->requiresConfig() === false) {
|
if ($this->requiresConfig() === false) {
|
||||||
if ($this->requiresLogin() === false) {
|
if ($this->requiresLogin() === false) {
|
||||||
|
|
|
@ -2,12 +2,27 @@
|
||||||
|
|
||||||
namespace Icinga\Web\Controller;
|
namespace Icinga\Web\Controller;
|
||||||
|
|
||||||
|
use Zend_Controller_Request_Abstract as Request;
|
||||||
|
use Zend_Controller_Response_Abstract as Response;
|
||||||
|
|
||||||
class ModuleActionController extends ActionController
|
class ModuleActionController extends ActionController
|
||||||
{
|
{
|
||||||
private $config;
|
private $config;
|
||||||
|
|
||||||
private $configs = array();
|
private $configs = array();
|
||||||
|
|
||||||
|
protected $moduleName;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
Request $request,
|
||||||
|
Response $response,
|
||||||
|
array $invokeArgs = array()
|
||||||
|
) {
|
||||||
|
parent::__construct($request, $response, $invokeArgs);
|
||||||
|
$this->moduleName = $request->getModuleName();
|
||||||
|
$this->view->translationDomain = $this->moduleName;
|
||||||
|
}
|
||||||
|
|
||||||
public function Config($file = null)
|
public function Config($file = null)
|
||||||
{
|
{
|
||||||
$module = $this->getRequest()->getModuleName();
|
$module = $this->getRequest()->getModuleName();
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Icinga\Web;
|
||||||
|
|
||||||
|
use Zend_Controller_Response_Http;
|
||||||
|
|
||||||
|
class Response extends Zend_Controller_Response_Http
|
||||||
|
{
|
||||||
|
}
|
|
@ -4,9 +4,9 @@
|
||||||
|
|
||||||
namespace Icinga\Module\Doc;
|
namespace Icinga\Module\Doc;
|
||||||
|
|
||||||
use Icinga\Web\Controller\ActionController;
|
use Icinga\Web\Controller\ModuleActionController;
|
||||||
|
|
||||||
class Controller extends ActionController
|
class Controller extends ModuleActionController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Set HTML and toc
|
* Set HTML and toc
|
||||||
|
|
|
@ -29,14 +29,14 @@
|
||||||
|
|
||||||
namespace Icinga\Module\Monitoring;
|
namespace Icinga\Module\Monitoring;
|
||||||
|
|
||||||
use Icinga\Web\Controller\ActionController;
|
use Icinga\Web\Controller\ModuleActionController;
|
||||||
use Icinga\Web\Url;
|
use Icinga\Web\Url;
|
||||||
use Icinga\File\Csv;
|
use Icinga\File\Csv;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for all monitoring action controller
|
* Base class for all monitoring action controller
|
||||||
*/
|
*/
|
||||||
class Controller extends ActionController
|
class Controller extends ModuleActionController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The backend used for this controller
|
* The backend used for this controller
|
||||||
|
|
Loading…
Reference in New Issue