diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 13:17:31 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 13:17:31 +0000 |
commit | f66ab8dae2f3d0418759f81a3a64dc9517a62449 (patch) | |
tree | fbff2135e7013f196b891bbde54618eb050e4aaf /library/Director/Data/ImportExportDeniedProperties.php | |
parent | Initial commit. (diff) | |
download | icingaweb2-module-director-f66ab8dae2f3d0418759f81a3a64dc9517a62449.tar.xz icingaweb2-module-director-f66ab8dae2f3d0418759f81a3a64dc9517a62449.zip |
Adding upstream version 1.10.2.upstream/1.10.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | library/Director/Data/ImportExportDeniedProperties.php | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/library/Director/Data/ImportExportDeniedProperties.php b/library/Director/Data/ImportExportDeniedProperties.php new file mode 100644 index 0000000..747eb0f --- /dev/null +++ b/library/Director/Data/ImportExportDeniedProperties.php @@ -0,0 +1,52 @@ +<?php + +namespace Icinga\Module\Director\Data; + +use Icinga\Module\Director\Data\Db\DbObject; +use Icinga\Module\Director\Objects\DirectorJob; +use Icinga\Module\Director\Objects\ImportRowModifier; +use Icinga\Module\Director\Objects\ImportSource; +use Icinga\Module\Director\Objects\SyncRule; + +class ImportExportDeniedProperties +{ + protected static $denyProperties = [ + DirectorJob::class => [ + 'last_attempt_succeeded', + 'last_error_message', + 'ts_last_attempt', + 'ts_last_error', + ], + ImportSource::class => [ + // No state export + 'import_state', + 'last_error_message', + 'last_attempt', + ], + ImportRowModifier::class => [ + // Not state, but to be removed: + 'source_id', + ], + SyncRule::class => [ + 'sync_state', + 'last_error_message', + 'last_attempt', + ], + ]; + + public static function strip(array &$props, DbObject $object, $showIds = false) + { + // TODO: this used to exist. Double-check all imports to verify it's not in use + // $originalId = $props['id']; + + if (! $showIds) { + unset($props['id']); + } + $class = get_class($object); + if (isset(self::$denyProperties[$class])) { + foreach (self::$denyProperties[$class] as $key) { + unset($props[$key]); + } + } + } +} |