summaryrefslogtreecommitdiffstats
path: root/library/Director/Data/ImportExportDeniedProperties.php
blob: 747eb0fc8642a828bab1e6f924aab88a206338a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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]);
            }
        }
    }
}