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
|
|
|
|
2021-03-17 12:53:36 -04:00
|
|
|
use Icinga\Module\Icingadb\Model\Behavior\ReRoute;
|
2022-05-19 10:28:45 -04:00
|
|
|
use ipl\Orm\Behavior\Binary;
|
2021-03-17 12:53:36 -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 $zone_id
|
|
|
|
|
* @property string $environment_id
|
|
|
|
|
* @property string $name_checksum
|
|
|
|
|
* @property string $properties_checksum
|
|
|
|
|
* @property string $name
|
|
|
|
|
* @property string $name_ci
|
|
|
|
|
* @property string $command
|
2024-03-14 06:52:09 -04:00
|
|
|
* @property int $timeout
|
2024-01-23 02:43:02 -05:00
|
|
|
*/
|
2019-09-23 09:31:18 -04:00
|
|
|
class Eventcommand extends Model
|
|
|
|
|
{
|
|
|
|
|
public function getTableName()
|
|
|
|
|
{
|
|
|
|
|
return 'eventcommand';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getKeyName()
|
|
|
|
|
{
|
|
|
|
|
return 'id';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getColumns()
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'zone_id',
|
|
|
|
|
'environment_id',
|
|
|
|
|
'name_checksum',
|
|
|
|
|
'properties_checksum',
|
|
|
|
|
'name',
|
|
|
|
|
'name_ci',
|
|
|
|
|
'command',
|
|
|
|
|
'timeout'
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
'zone_id' => t('Zone Id'),
|
2022-07-14 09:42:24 -04:00
|
|
|
'environment_id' => t('Environment Id'),
|
2021-03-08 05:40:16 -05:00
|
|
|
'name_checksum' => t('Eventcommand Name Checksum'),
|
|
|
|
|
'properties_checksum' => t('Eventcommand Properties Checksum'),
|
|
|
|
|
'name' => t('Eventcommand Name'),
|
|
|
|
|
'name_ci' => t('Eventcommand Name (CI)'),
|
|
|
|
|
'command' => t('Eventcommand'),
|
|
|
|
|
'timeout' => t('Eventcommand Timeout')
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-17 12:53:36 -04:00
|
|
|
public function createBehaviors(Behaviors $behaviors)
|
|
|
|
|
{
|
|
|
|
|
$behaviors->add(new ReRoute([
|
|
|
|
|
'hostgroup' => 'host.hostgroup',
|
|
|
|
|
'servicegroup' => 'service.servicegroup'
|
|
|
|
|
]));
|
2022-03-29 09:27:18 -04:00
|
|
|
|
|
|
|
|
$behaviors->add(new Binary([
|
|
|
|
|
'id',
|
|
|
|
|
'zone_id',
|
|
|
|
|
'environment_id',
|
|
|
|
|
'name_checksum',
|
|
|
|
|
'properties_checksum'
|
|
|
|
|
]));
|
2021-03-17 12:53:36 -04:00
|
|
|
}
|
|
|
|
|
|
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)
|
2025-07-07 09:16:48 -04:00
|
|
|
->through(EventcommandCustomvar::class)
|
|
|
|
|
->setThroughAlias('t_eventcommand_customvar');
|
2019-09-23 09:31:18 -04:00
|
|
|
$relations->belongsToMany('customvar_flat', CustomvarFlat::class)
|
2019-11-19 08:22:17 -05:00
|
|
|
->through(EventcommandCustomvar::class);
|
2022-05-19 09:48:10 -04:00
|
|
|
$relations->belongsToMany('vars', Vars::class)
|
2020-11-03 04:24:16 -05:00
|
|
|
->through(EventcommandCustomvar::class);
|
2019-09-23 09:31:18 -04:00
|
|
|
|
2021-10-18 11:45:34 -04:00
|
|
|
$relations->hasMany('argument', EventcommandArgument::class);
|
|
|
|
|
$relations->hasMany('envvar', EventcommandEnvvar::class);
|
2019-09-23 09:31:18 -04:00
|
|
|
$relations->hasMany('host', Host::class);
|
|
|
|
|
$relations->hasMany('service', Service::class);
|
|
|
|
|
}
|
|
|
|
|
}
|