ServiceCommand: extract override-logic

This commit is contained in:
Thomas Gelf 2022-07-20 08:34:05 +02:00
parent 706a9b1fc1
commit 02bed9265a

View File

@ -18,8 +18,16 @@ class ServiceCommand extends ObjectCommand
public function setAction()
{
if (($host = $this->params->get('host')) && $this->params->shift('allow-overrides')) {
$this->setServiceProperties($host);
}
parent::setAction();
}
protected function setServiceProperties($hostname)
{
$name = $this->getName();
$host = IcingaHost::load($host, $this->db());
$host = IcingaHost::load($hostname, $this->db());
$service = ServiceFinder::find($host, $name);
if ($service->requiresOverrides()) {
$this->params->shift('host');
@ -58,9 +66,6 @@ class ServiceCommand extends ObjectCommand
}
}
parent::setAction();
}
protected static function assertVarsForOverrides($properties)
{
if (empty($properties)) {