Extend the Web bootstrapper from the EmbeddedWeb bootstrapper
In a embedded web environment we may also need a request and response. refs #9702
This commit is contained in:
parent
4c00d5effc
commit
59ef54314a
|
@ -5,6 +5,9 @@ namespace Icinga\Application;
|
|||
|
||||
require_once dirname(__FILE__) . '/ApplicationBootstrap.php';
|
||||
|
||||
use Icinga\Web\Request;
|
||||
use Icinga\Web\Response;
|
||||
|
||||
/**
|
||||
* Use this if you want to make use of Icinga functionality in other web projects
|
||||
*
|
||||
|
@ -16,6 +19,40 @@ require_once dirname(__FILE__) . '/ApplicationBootstrap.php';
|
|||
*/
|
||||
class EmbeddedWeb extends ApplicationBootstrap
|
||||
{
|
||||
/**
|
||||
* Request object
|
||||
*
|
||||
* @var Request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* Response
|
||||
*
|
||||
* @var Response
|
||||
*/
|
||||
protected $response;
|
||||
|
||||
/**
|
||||
* Get the request
|
||||
*
|
||||
* @return Request
|
||||
*/
|
||||
public function getRequest()
|
||||
{
|
||||
return $this->request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the response
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function getResponse()
|
||||
{
|
||||
return $this->response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Embedded bootstrap parts
|
||||
*
|
||||
|
@ -26,10 +63,34 @@ class EmbeddedWeb extends ApplicationBootstrap
|
|||
{
|
||||
return $this
|
||||
->setupZendAutoloader()
|
||||
->loadConfig()
|
||||
->setupErrorHandling()
|
||||
->loadConfig()
|
||||
->setupRequest()
|
||||
->setupResponse()
|
||||
->setupTimezone()
|
||||
->setupModuleManager()
|
||||
->loadEnabledModules();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the request
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
protected function setupRequest()
|
||||
{
|
||||
$this->request = new Request();
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the response
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
protected function setupResponse()
|
||||
{
|
||||
$this->response = new Response();
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
namespace Icinga\Application;
|
||||
|
||||
require_once __DIR__ . '/ApplicationBootstrap.php';
|
||||
require_once __DIR__ . '/EmbeddedWeb.php';
|
||||
|
||||
use Zend_Controller_Action_HelperBroker;
|
||||
use Zend_Controller_Front;
|
||||
|
@ -11,14 +11,11 @@ use Zend_Controller_Router_Route;
|
|||
use Zend_Layout;
|
||||
use Zend_Paginator;
|
||||
use Zend_View_Helper_PaginationControl;
|
||||
use Icinga\Application\Logger;
|
||||
use Icinga\Authentication\Auth;
|
||||
use Icinga\User;
|
||||
use Icinga\Util\TimezoneDetect;
|
||||
use Icinga\Util\Translator;
|
||||
use Icinga\Web\Notification;
|
||||
use Icinga\Web\Request;
|
||||
use Icinga\Web\Response;
|
||||
use Icinga\Web\Session;
|
||||
use Icinga\Web\Session\Session as BaseSession;
|
||||
use Icinga\Web\View;
|
||||
|
@ -28,11 +25,11 @@ use Icinga\Web\View;
|
|||
*
|
||||
* Usage example:
|
||||
* <code>
|
||||
* use Icinga\Application\EmbeddedWeb;
|
||||
* EmbeddedWeb::start();
|
||||
* use Icinga\Application\Web;
|
||||
* Web::start();
|
||||
* </code>
|
||||
*/
|
||||
class Web extends ApplicationBootstrap
|
||||
class Web extends EmbeddedWeb
|
||||
{
|
||||
/**
|
||||
* View object
|
||||
|
@ -48,20 +45,6 @@ class Web extends ApplicationBootstrap
|
|||
*/
|
||||
private $frontController;
|
||||
|
||||
/**
|
||||
* Request object
|
||||
*
|
||||
* @var Request
|
||||
*/
|
||||
private $request;
|
||||
|
||||
/**
|
||||
* Response
|
||||
*
|
||||
* @var Response
|
||||
*/
|
||||
protected $response;
|
||||
|
||||
/**
|
||||
* Session object
|
||||
*
|
||||
|
@ -145,26 +128,6 @@ class Web extends ApplicationBootstrap
|
|||
return $this->frontController;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the request
|
||||
*
|
||||
* @return Request
|
||||
*/
|
||||
public function getRequest()
|
||||
{
|
||||
return $this->request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the response
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function getResponse()
|
||||
{
|
||||
return $this->response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for view
|
||||
*
|
||||
|
@ -211,7 +174,7 @@ class Web extends ApplicationBootstrap
|
|||
$auth = Auth::getInstance();
|
||||
if ($auth->isAuthenticated()) {
|
||||
$user = $auth->getUser();
|
||||
$this->request->setUser($user);
|
||||
$this->getRequest()->setUser($user);
|
||||
$this->user = $user;
|
||||
}
|
||||
return $this;
|
||||
|
@ -239,28 +202,6 @@ class Web extends ApplicationBootstrap
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the request
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
private function setupRequest()
|
||||
{
|
||||
$this->request = new Request();
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the response
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
protected function setupResponse()
|
||||
{
|
||||
$this->response = new Response();
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate front controller
|
||||
*
|
||||
|
@ -269,7 +210,7 @@ class Web extends ApplicationBootstrap
|
|||
private function setupFrontController()
|
||||
{
|
||||
$this->frontController = Zend_Controller_Front::getInstance();
|
||||
$this->frontController->setRequest($this->request);
|
||||
$this->frontController->setRequest($this->getRequest());
|
||||
$this->frontController->setControllerDirectory($this->getApplicationDir('/controllers'));
|
||||
$this->frontController->setParams(
|
||||
array(
|
||||
|
|
Loading…
Reference in New Issue