icingadb-web/library/Icingadb/Model/Notificationcommand.php

100 lines
3 KiB
PHP
Raw Permalink Normal View History

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
use Icinga\Module\Icingadb\Model\Behavior\ReRoute;
use ipl\Orm\Behavior\Binary;
use ipl\Orm\Behaviors;
use Icinga\Module\Icingadb\Common\Model;
2019-09-23 09:31:18 -04:00
use ipl\Orm\Relations;
/**
* @property string $id
* @property ?string $zone_id
* @property string $environment_id
* @property string $name_checksum
* @property string $properties_checksum
* @property string $name
* @property string $name_ci
* @property string $command
* @property int $timeout
*/
2019-09-23 09:31:18 -04:00
class Notificationcommand extends Model
{
public function getTableName()
{
return 'notificationcommand';
}
public function getKeyName()
{
return 'id';
}
public function getColumns()
{
return [
'zone_id',
'environment_id',
'name_checksum',
'properties_checksum',
'name',
'name_ci',
'command',
'timeout'
];
}
public function getColumnDefinitions()
{
return [
2022-07-11 11:31:53 -04:00
'zone_id' => t('Zone Id'),
'environment_id' => t('Environment Id'),
'name_checksum' => t('Notificationcommand Name Checksum'),
'properties_checksum' => t('Notificationcommand Properties Checksum'),
'name' => t('Notificationcommand Name'),
'name_ci' => t('Notificationcommand Name (CI)'),
'command' => t('Notificationcommand'),
'timeout' => t('Notificationcommand Timeout')
];
}
public function createBehaviors(Behaviors $behaviors)
{
$behaviors->add(new ReRoute([
'host' => 'notification.host',
'hostgroup' => 'notification.host.hostgroup',
'service' => 'notification.service',
'servicegroup' => 'notification.service.servicegroup'
]));
2022-03-29 09:27:18 -04:00
$behaviors->add(new Binary([
'id',
'zone_id',
'environment_id',
'name_checksum',
'properties_checksum'
]));
}
2019-09-23 09:31:18 -04:00
public function createRelations(Relations $relations)
{
$relations->belongsTo('environment', Environment::class);
$relations->belongsTo('zone', Zone::class);
$relations->belongsToMany('customvar', Customvar::class)
->through(NotificationcommandCustomvar::class)
->setThroughAlias('t_notificationcommand_customvar');
2019-09-23 09:31:18 -04:00
$relations->belongsToMany('customvar_flat', CustomvarFlat::class)
->through(NotificationcommandCustomvar::class);
$relations->belongsToMany('vars', Vars::class)
->through(NotificationcommandCustomvar::class);
2019-09-23 09:31:18 -04:00
$relations->hasMany('notification', Notification::class);
$relations->hasMany('argument', NotificationcommandArgument::class);
$relations->hasMany('envvar', NotificationcommandEnvvar::class);
2019-09-23 09:31:18 -04:00
}
}