ObjectController: refactor initalization

This commit is contained in:
Thomas Gelf 2022-07-20 09:59:22 +02:00
parent 34d5e445b2
commit 13c09855fa

View File

@ -63,8 +63,15 @@ abstract class ObjectController extends ActionController
{
parent::init();
$this->enableStaticObjectLoader($this->getTableName());
if ($this->getRequest()->isApiRequest()) {
$this->initializeRestApi();
} else {
$this->initializeWebRequest();
}
}
protected function initializeRestApi()
{
$handler = new IcingaObjectHandler($this->getRequest(), $this->getResponse(), $this->db());
try {
$this->loadOptionalObject();
@ -86,7 +93,10 @@ abstract class ObjectController extends ActionController
// different view renderers - hard exit is the only safe bet right
// now.
exit;
} else {
}
protected function initializeWebRequest()
{
$this->loadOptionalObject();
if ($this->getRequest()->getActionName() === 'add') {
$this->addSingleTab(
@ -105,7 +115,6 @@ abstract class ObjectController extends ActionController
$this->addDeploymentLink();
}
}
}
/**
* @throws NotFoundError