ObjectController: failsafe api access
This commit is contained in:
parent
f25b47e1bc
commit
c1185106fa
|
@ -219,6 +219,18 @@ abstract class ActionController extends Controller
|
|||
return $this;
|
||||
}
|
||||
|
||||
protected function getApiIfAvailable()
|
||||
{
|
||||
if ($this->api === null) {
|
||||
if ($this->db->hasDeploymentEndpoint()) {
|
||||
$endpoint = $this->db()->getDeploymentEndpoint();
|
||||
$this->api = $endpoint->api();
|
||||
}
|
||||
}
|
||||
|
||||
return $this->api;
|
||||
}
|
||||
|
||||
protected function api($endpointName = null)
|
||||
{
|
||||
if ($this->api === null) {
|
||||
|
|
|
@ -148,7 +148,7 @@ abstract class ObjectController extends ActionController
|
|||
$formName = 'icinga' . $type;
|
||||
$this->view->form = $form = $this->loadForm($formName)
|
||||
->setDb($this->db())
|
||||
->setApi($this->api());
|
||||
->setApi($this->getApiIfAvailable());
|
||||
$form->setObject($object);
|
||||
|
||||
$this->view->title = $object->object_name;
|
||||
|
@ -177,7 +177,7 @@ abstract class ObjectController extends ActionController
|
|||
$url = sprintf('director/%ss', $ltype);
|
||||
$form = $this->view->form = $this->loadForm('icinga' . ucfirst($type))
|
||||
->setDb($this->db())
|
||||
->setApi($this->api())
|
||||
->setApi($this->getApiIfAvailable())
|
||||
->setSuccessUrl($url);
|
||||
|
||||
$this->view->title = sprintf(
|
||||
|
|
Loading…
Reference in New Issue