ObjectController: Don't let DeploymentLink break the interface on errors

This can happen whenever the deployment related config of Zones,
Endpoints or ApiUsers is incomplete or missing.

This should not break forms needed to fix the problem.
This commit is contained in:
Markus Frosch 2017-10-20 10:23:23 +02:00 committed by Thomas Gelf
parent 44c2a1b7db
commit efc36fdbb8
1 changed files with 16 additions and 11 deletions

View File

@ -2,6 +2,7 @@
namespace Icinga\Module\Director\Web\Controller;
use Icinga\Exception\IcingaException;
use Icinga\Exception\InvalidPropertyException;
use Icinga\Exception\NotFoundError;
use Icinga\Module\Director\Deployment\DeploymentInfo;
@ -379,18 +380,22 @@ abstract class ObjectController extends ActionController
protected function addDeploymentLink()
{
$info = new DeploymentInfo($this->db());
$info->setObject($this->object);
try {
$info = new DeploymentInfo($this->db());
$info->setObject($this->object);
if (! $this->getRequest()->isApiRequest()) {
$this->actions()->add(
DeploymentLinkForm::create(
$this->db(),
$info,
$this->Auth(),
$this->api()
)->handleRequest()
);
if (! $this->getRequest()->isApiRequest()) {
$this->actions()->add(
DeploymentLinkForm::create(
$this->db(),
$info,
$this->Auth(),
$this->api()
)->handleRequest()
);
}
} catch (IcingaException $e) {
// pass (deployment may not be set up yet)
}
}