mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-31 01:34:12 +02:00
IcingaServiceForm: getFirstParent() prepared to...
...be moved elsewhere
This commit is contained in:
parent
33c4c078d4
commit
8cbde4a50e
@ -9,6 +9,7 @@ use Icinga\Exception\ProgrammingError;
|
|||||||
use Icinga\Module\Director\Auth\Permission;
|
use Icinga\Module\Director\Auth\Permission;
|
||||||
use Icinga\Module\Director\Data\PropertiesFilter\ArrayCustomVariablesFilter;
|
use Icinga\Module\Director\Data\PropertiesFilter\ArrayCustomVariablesFilter;
|
||||||
use Icinga\Module\Director\Exception\NestingError;
|
use Icinga\Module\Director\Exception\NestingError;
|
||||||
|
use Icinga\Module\Director\Objects\IcingaObject;
|
||||||
use Icinga\Module\Director\Web\Form\DirectorObjectForm;
|
use Icinga\Module\Director\Web\Form\DirectorObjectForm;
|
||||||
use Icinga\Module\Director\Objects\IcingaHost;
|
use Icinga\Module\Director\Objects\IcingaHost;
|
||||||
use Icinga\Module\Director\Objects\IcingaService;
|
use Icinga\Module\Director\Objects\IcingaService;
|
||||||
@ -197,14 +198,16 @@ class IcingaServiceForm extends DirectorObjectForm
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param IcingaService $service
|
* Hint: could be moved elsewhere
|
||||||
* @return IcingaService
|
*
|
||||||
|
* @param IcingaService $object
|
||||||
|
* @return IcingaObject|IcingaService|IcingaServiceSet
|
||||||
* @throws \Icinga\Exception\NotFoundError
|
* @throws \Icinga\Exception\NotFoundError
|
||||||
*/
|
*/
|
||||||
protected function getFirstParent(IcingaService $service)
|
protected static function getFirstParent(IcingaObject $object)
|
||||||
{
|
{
|
||||||
/** @var IcingaService[] $objects */
|
/** @var IcingaObject[] $objects */
|
||||||
$objects = $service->imports()->getObjects();
|
$objects = $object->imports()->getObjects();
|
||||||
if (empty($objects)) {
|
if (empty($objects)) {
|
||||||
throw new RuntimeException('Something went wrong, got no parent');
|
throw new RuntimeException('Something went wrong, got no parent');
|
||||||
}
|
}
|
||||||
@ -301,7 +304,7 @@ class IcingaServiceForm extends DirectorObjectForm
|
|||||||
if ($this->set) {
|
if ($this->set) {
|
||||||
return $this->object;
|
return $this->object;
|
||||||
} else {
|
} else {
|
||||||
return $this->getFirstParent($this->object);
|
return self::getFirstParent($this->object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user