summaryrefslogtreecommitdiffstats
path: root/library/Icingadb/Model/Zone.php
blob: 04d63ce9d4d674f12852c655035daaf984aa760a (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php

/* Icinga DB Web | (c) 2020 Icinga GmbH | GPLv2 */

namespace Icinga\Module\Icingadb\Model;

use ipl\Orm\Behavior\Binary;
use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;

/**
 * @property string $id
 * @property string $environment_id
 * @property string $name_checksum
 * @property string $properties_checksum
 * @property string $name
 * @property string $name_ci
 * @property string $is_global
 * @property ?string $parent_id
 * @property int $depth
 */
class Zone extends Model
{
    public function getTableName()
    {
        return 'zone';
    }

    public function getKeyName()
    {
        return 'id';
    }

    public function getColumns()
    {
        return [
            'environment_id',
            'name_checksum',
            'properties_checksum',
            'name',
            'name_ci',
            'is_global',
            'parent_id',
            'depth'
        ];
    }

    public function getColumnDefinitions()
    {
        return [
            'environment_id'        => t('Environment Id'),
            'name_checksum'         => t('Zone Name Checksum'),
            'properties_checksum'   => t('Zone Properties Checksum'),
            'name'                  => t('Zone Name'),
            'name_ci'               => t('Zone Name (CI)'),
            'is_global'             => t('Zone Is Global'),
            'parent_id'             => t('Parent Zone Id'),
            'depth'                 => t('Zone Depth')
        ];
    }

    public function createBehaviors(Behaviors $behaviors)
    {
        $behaviors->add(new Binary([
            'id',
            'environment_id',
            'name_checksum',
            'properties_checksum',
            'parent_id'
        ]));
    }

    public function createRelations(Relations $relations)
    {
        $relations->belongsTo('environment', Environment::class);

        $relations->hasMany('comment', Comment::class);
        $relations->hasMany('downtime', Downtime::class);
        $relations->hasMany('endpoint', Endpoint::class);
        $relations->hasMany('eventcommand', Eventcommand::class);
        $relations->hasMany('host', Host::class);
        $relations->hasMany('hostgroup', Hostgroup::class);
        $relations->hasMany('notification', Notification::class);
        $relations->hasMany('service', Service::class);
        $relations->hasMany('servicegroup', Servicegroup::class);
        $relations->hasMany('timeperiod', Timeperiod::class);
        $relations->hasMany('user', User::class);
        $relations->hasMany('usergroup', Usergroup::class);

        // TODO: Decide how to establish recursive relations
    }
}