mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-31 01:34:12 +02:00
ObjectController: refactor initalization
This commit is contained in:
parent
34d5e445b2
commit
13c09855fa
@ -63,8 +63,15 @@ abstract class ObjectController extends ActionController
|
|||||||
{
|
{
|
||||||
parent::init();
|
parent::init();
|
||||||
$this->enableStaticObjectLoader($this->getTableName());
|
$this->enableStaticObjectLoader($this->getTableName());
|
||||||
|
|
||||||
if ($this->getRequest()->isApiRequest()) {
|
if ($this->getRequest()->isApiRequest()) {
|
||||||
|
$this->initializeRestApi();
|
||||||
|
} else {
|
||||||
|
$this->initializeWebRequest();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function initializeRestApi()
|
||||||
|
{
|
||||||
$handler = new IcingaObjectHandler($this->getRequest(), $this->getResponse(), $this->db());
|
$handler = new IcingaObjectHandler($this->getRequest(), $this->getResponse(), $this->db());
|
||||||
try {
|
try {
|
||||||
$this->loadOptionalObject();
|
$this->loadOptionalObject();
|
||||||
@ -86,7 +93,10 @@ abstract class ObjectController extends ActionController
|
|||||||
// different view renderers - hard exit is the only safe bet right
|
// different view renderers - hard exit is the only safe bet right
|
||||||
// now.
|
// now.
|
||||||
exit;
|
exit;
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
protected function initializeWebRequest()
|
||||||
|
{
|
||||||
$this->loadOptionalObject();
|
$this->loadOptionalObject();
|
||||||
if ($this->getRequest()->getActionName() === 'add') {
|
if ($this->getRequest()->getActionName() === 'add') {
|
||||||
$this->addSingleTab(
|
$this->addSingleTab(
|
||||||
@ -105,7 +115,6 @@ abstract class ObjectController extends ActionController
|
|||||||
$this->addDeploymentLink();
|
$this->addDeploymentLink();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws NotFoundError
|
* @throws NotFoundError
|
||||||
|
Loading…
x
Reference in New Issue
Block a user