2019-09-23 09:31:18 -04:00
|
|
|
<?php
|
|
|
|
|
|
2020-03-13 03:38:01 -04:00
|
|
|
/* Icinga DB Web | (c) 2020 Icinga GmbH | GPLv2 */
|
|
|
|
|
|
2019-11-04 19:07:30 -05:00
|
|
|
namespace Icinga\Module\Icingadb\Model;
|
2019-09-23 09:31:18 -04:00
|
|
|
|
2022-05-19 10:28:45 -04:00
|
|
|
use ipl\Orm\Behavior\Binary;
|
2022-03-29 09:27:18 -04:00
|
|
|
use ipl\Orm\Behaviors;
|
2025-10-16 02:42:51 -04:00
|
|
|
use Icinga\Module\Icingadb\Common\Model;
|
2019-09-23 09:31:18 -04:00
|
|
|
use ipl\Orm\Relations;
|
|
|
|
|
|
2024-01-23 02:43:02 -05:00
|
|
|
/**
|
|
|
|
|
* @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
|
2024-03-14 06:52:09 -04:00
|
|
|
* @property int $depth
|
2024-01-23 02:43:02 -05:00
|
|
|
*/
|
2019-09-23 09:31:18 -04:00
|
|
|
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'
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-08 09:34:01 -04:00
|
|
|
public function getColumnDefinitions()
|
2021-03-08 05:40:16 -05:00
|
|
|
{
|
|
|
|
|
return [
|
2022-07-11 11:31:53 -04:00
|
|
|
'environment_id' => t('Environment Id'),
|
2021-03-08 05:40:16 -05:00
|
|
|
'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'),
|
2022-07-11 11:31:53 -04:00
|
|
|
'parent_id' => t('Parent Zone Id'),
|
2021-03-08 05:40:16 -05:00
|
|
|
'depth' => t('Zone Depth')
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-29 09:27:18 -04:00
|
|
|
public function createBehaviors(Behaviors $behaviors)
|
|
|
|
|
{
|
|
|
|
|
$behaviors->add(new Binary([
|
|
|
|
|
'id',
|
|
|
|
|
'environment_id',
|
|
|
|
|
'name_checksum',
|
|
|
|
|
'properties_checksum',
|
|
|
|
|
'parent_id'
|
|
|
|
|
]));
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-23 09:31:18 -04:00
|
|
|
public function createRelations(Relations $relations)
|
|
|
|
|
{
|
|
|
|
|
$relations->belongsTo('environment', Environment::class);
|
|
|
|
|
|
2020-03-10 07:41:14 -04:00
|
|
|
$relations->hasMany('comment', Comment::class);
|
|
|
|
|
$relations->hasMany('downtime', Downtime::class);
|
2019-09-23 09:31:18 -04:00
|
|
|
$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
|
|
|
|
|
}
|
|
|
|
|
}
|