2016-10-13 11:13:21 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Icinga\Module\Director\Controllers;
|
|
|
|
|
|
|
|
use Icinga\Module\Director\Objects\IcingaHost;
|
|
|
|
use Icinga\Module\Director\Objects\IcingaServiceSet;
|
|
|
|
use Icinga\Module\Director\Web\Controller\ObjectController;
|
|
|
|
|
|
|
|
class ServicesetController extends ObjectController
|
|
|
|
{
|
|
|
|
protected $host;
|
|
|
|
|
|
|
|
public function init()
|
|
|
|
{
|
|
|
|
if ($host = $this->params->get('host')) {
|
|
|
|
$this->host = IcingaHost::load($host, $this->db());
|
|
|
|
}
|
|
|
|
|
|
|
|
parent::init();
|
|
|
|
}
|
|
|
|
|
2016-10-20 09:22:08 +02:00
|
|
|
public function loadForm($name)
|
|
|
|
{
|
|
|
|
$form = parent::loadForm($name);
|
|
|
|
if ($name === 'icingaServiceSet' && $this->host) {
|
|
|
|
$form->setHost($this->host);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $form;
|
|
|
|
}
|
|
|
|
|
2016-10-13 11:13:21 +02:00
|
|
|
protected function loadObject()
|
|
|
|
{
|
|
|
|
if ($this->object === null) {
|
|
|
|
if ($name = $this->params->get('name')) {
|
|
|
|
$params = array('object_name' => $name);
|
|
|
|
$db = $this->db();
|
|
|
|
|
|
|
|
if ($this->host) {
|
|
|
|
$this->view->host = $this->host;
|
|
|
|
$params['host_id'] = $this->host->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->object = IcingaServiceSet::load($params, $db);
|
|
|
|
} else {
|
|
|
|
parent::loadObject();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->object;
|
|
|
|
}
|
|
|
|
}
|