mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-30 17:24:18 +02:00
IcingaServiceSet: Check if object_name is unique for templates
refs #13309
This commit is contained in:
parent
ab169e4b78
commit
3a8cad2486
@ -4,6 +4,7 @@ namespace Icinga\Module\Director\Objects;
|
|||||||
|
|
||||||
use Icinga\Data\Filter\Filter;
|
use Icinga\Data\Filter\Filter;
|
||||||
use Icinga\Exception\IcingaException;
|
use Icinga\Exception\IcingaException;
|
||||||
|
use Icinga\Module\Director\Exception\DuplicateKeyException;
|
||||||
use Icinga\Module\Director\IcingaConfig\IcingaConfig;
|
use Icinga\Module\Director\IcingaConfig\IcingaConfig;
|
||||||
|
|
||||||
|
|
||||||
@ -249,4 +250,17 @@ class IcingaServiceSet extends IcingaObject
|
|||||||
return $host->getRenderingZone($config);
|
return $host->getRenderingZone($config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function beforeStore()
|
||||||
|
{
|
||||||
|
parent::beforeStore();
|
||||||
|
|
||||||
|
$name = $this->getObjectName();
|
||||||
|
|
||||||
|
// checking if template object_name is unique
|
||||||
|
// TODO: Move to IcingaObject
|
||||||
|
if (! $this->hasBeenLoadedFromDb() && $this->isTemplate() && static::exists($name, $this->connection)) {
|
||||||
|
throw new DuplicateKeyException('%s template "%s" already existing in database!', $this->getType(), $name);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user