summaryrefslogtreecommitdiffstats
path: root/library/Director/Objects/IcingaHost.php
diff options
context:
space:
mode:
Diffstat (limited to 'library/Director/Objects/IcingaHost.php')
-rw-r--r--library/Director/Objects/IcingaHost.php85
1 files changed, 7 insertions, 78 deletions
diff --git a/library/Director/Objects/IcingaHost.php b/library/Director/Objects/IcingaHost.php
index 2731f4a..7859324 100644
--- a/library/Director/Objects/IcingaHost.php
+++ b/library/Director/Objects/IcingaHost.php
@@ -7,7 +7,6 @@ use Icinga\Exception\NotFoundError;
use Icinga\Module\Director\Data\PropertiesFilter;
use Icinga\Module\Director\Db;
use Icinga\Module\Director\DirectorObject\Automation\ExportInterface;
-use Icinga\Module\Director\Exception\DuplicateKeyException;
use Icinga\Module\Director\IcingaConfig\IcingaConfig;
use Icinga\Module\Director\IcingaConfig\IcingaConfigHelper as c;
use Icinga\Module\Director\IcingaConfig\IcingaLegacyConfigHelper as c1;
@@ -310,88 +309,18 @@ class IcingaHost extends IcingaObject implements ExportInterface
}
}
- /**
- * @return object
- * @deprecated please use \Icinga\Module\Director\Data\Exporter
- * @throws \Icinga\Exception\NotFoundError
- */
- public function export()
+ protected function rendersConditionalTemplate(): bool
{
- // TODO: ksort in toPlainObject?
- $props = (array) $this->toPlainObject();
- $props['fields'] = $this->loadFieldReferences();
- ksort($props);
-
- return (object) $props;
- }
-
- /**
- * @param $plain
- * @param Db $db
- * @param bool $replace
- * @return IcingaHost
- * @throws DuplicateKeyException
- * @throws \Icinga\Exception\NotFoundError
- */
- public static function import($plain, Db $db, $replace = false)
- {
- $properties = (array) $plain;
- $name = $properties['object_name'];
- if ($properties['object_type'] !== 'template') {
- throw new InvalidArgumentException(sprintf(
- 'Can import only Templates, got "%s" for "%s"',
- $properties['object_type'],
- $name
- ));
- }
- $key = $name;
-
- if ($replace && static::exists($key, $db)) {
- $object = static::load($key, $db);
- } elseif (static::exists($key, $db)) {
- throw new DuplicateKeyException(
- 'Service Template "%s" already exists',
- $name
- );
- } else {
- $object = static::create([], $db);
- }
-
- // $object->newFields = $properties['fields'];
- unset($properties['fields']);
- $object->setProperties($properties);
-
- return $object;
+ return $this->getRenderingZone() === self::ALL_NON_GLOBAL_ZONES;
}
- /**
- * @deprecated please use \Icinga\Module\Director\Data\FieldReferenceLoader
- * @return array
- */
- protected function loadFieldReferences()
+ protected function getDefaultZone(IcingaConfig $config = null)
{
- $db = $this->getDb();
-
- $res = $db->fetchAll(
- $db->select()->from([
- 'hf' => 'icinga_host_field'
- ], [
- 'hf.datafield_id',
- 'hf.is_required',
- 'hf.var_filter',
- ])->join(['df' => 'director_datafield'], 'df.id = hf.datafield_id', [])
- ->where('host_id = ?', $this->get('id'))
- ->order('varname ASC')
- );
-
- if (empty($res)) {
- return [];
- } else {
- foreach ($res as $field) {
- $field->datafield_id = (int) $field->datafield_id;
- }
- return $res;
+ if ($this->isTemplate()) {
+ return self::ALL_NON_GLOBAL_ZONES;
}
+
+ return parent::getDefaultZone();
}
public function beforeDelete()