summaryrefslogtreecommitdiffstats
path: root/library/Director/Objects/IcingaTemplateChoice.php
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 13:17:47 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 13:17:47 +0000
commit5419d4428c86c488a43124f85e5407d7cbae6541 (patch)
tree772c4221a20fd7d1b3e7e67c6e21755a50e80fd7 /library/Director/Objects/IcingaTemplateChoice.php
parentAdding upstream version 1.10.2. (diff)
downloadicingaweb2-module-director-upstream.tar.xz
icingaweb2-module-director-upstream.zip
Adding upstream version 1.11.1.upstream/1.11.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/Director/Objects/IcingaTemplateChoice.php')
-rw-r--r--library/Director/Objects/IcingaTemplateChoice.php63
1 files changed, 2 insertions, 61 deletions
diff --git a/library/Director/Objects/IcingaTemplateChoice.php b/library/Director/Objects/IcingaTemplateChoice.php
index 1a1be90..a2be07a 100644
--- a/library/Director/Objects/IcingaTemplateChoice.php
+++ b/library/Director/Objects/IcingaTemplateChoice.php
@@ -3,9 +3,7 @@
namespace Icinga\Module\Director\Objects;
use Icinga\Exception\ProgrammingError;
-use Icinga\Module\Director\Db;
use Icinga\Module\Director\DirectorObject\Automation\ExportInterface;
-use Icinga\Module\Director\Exception\DuplicateKeyException;
use Icinga\Module\Director\Web\Form\QuickForm;
class IcingaTemplateChoice extends IcingaObject implements ExportInterface
@@ -36,63 +34,6 @@ class IcingaTemplateChoice extends IcingaObject implements ExportInterface
return $this->getObjectName();
}
- /**
- * @param $plain
- * @param Db $db
- * @param bool $replace
- * @return IcingaTemplateChoice
- * @throws DuplicateKeyException
- * @throws \Icinga\Exception\NotFoundError
- */
- public static function import($plain, Db $db, $replace = false)
- {
- $properties = (array) $plain;
- if (isset($properties['originalId'])) {
- unset($properties['originalId']);
- }
- $name = $properties['object_name'];
- $key = $name;
-
- if ($replace && static::exists($key, $db)) {
- $object = static::load($key, $db);
- } elseif (static::exists($key, $db)) {
- throw new DuplicateKeyException(
- 'Template Choice "%s" already exists',
- $name
- );
- } else {
- $object = static::create([], $db);
- }
-
- $object->setProperties($properties);
-
- return $object;
- }
-
- /**
- * @deprecated please use \Icinga\Module\Director\Data\Exporter
- * @return array|object|\stdClass
- */
- public function export()
- {
- $plain = (object) $this->getProperties();
- $plain->originalId = $plain->id;
- unset($plain->id);
- $requiredId = $plain->required_template_id;
- unset($plain->required_template_id);
- if ($requiredId) {
- $db = $this->getDb();
- $query = $db->select()
- ->from(['o' => $this->getObjectTableName()], 'o.object_name')->where("o.object_type = 'template'")
- ->where('o.id = ?', $this->get('id'));
- $plain->required_template = $db->fetchOne($query);
- }
-
- $plain->members = array_values($this->getMembers());
-
- return $plain;
- }
-
public function isMainChoice()
{
return $this->hasBeenLoadedFromDb()
@@ -155,7 +96,7 @@ class IcingaTemplateChoice extends IcingaObject implements ExportInterface
public function hasBeenModified()
{
- if ($this->newChoices !== null && $this->choices !== $this->newChoices) {
+ if ($this->newChoices !== null && ($this->choices ?? $this->fetchChoices()) !== $this->newChoices) {
return true;
}
@@ -284,7 +225,7 @@ class IcingaTemplateChoice extends IcingaObject implements ExportInterface
} else {
throw new ProgrammingError(
'Expected array or null for allowed_roles, got %s',
- var_export($roles, 1)
+ var_export($roles, true)
);
}
}