mirror of
https://github.com/Icinga/icingadb-web.git
synced 2026-05-28 04:36:06 -04:00
Host/Service: Transform y|n enums to true|false
This commit is contained in:
parent
f93dcd1d9e
commit
88ccf14907
3 changed files with 37 additions and 0 deletions
11
library/Eagle/Model/Behavior/BoolCast.php
Normal file
11
library/Eagle/Model/Behavior/BoolCast.php
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace Icinga\Module\Eagle\Model\Behavior;
|
||||
|
||||
class BoolCast extends PropertiesBehavior
|
||||
{
|
||||
public function __invoke($value, $key)
|
||||
{
|
||||
return $value === 'y';
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace Icinga\Module\Eagle\Model;
|
||||
|
||||
use Icinga\Module\Eagle\Model\Behavior\BoolCast;
|
||||
use ipl\Orm\Behaviors;
|
||||
use ipl\Orm\Model;
|
||||
use ipl\Orm\Relations;
|
||||
|
||||
|
|
@ -66,6 +68,17 @@ class Host extends Model
|
|||
];
|
||||
}
|
||||
|
||||
public function createBehaviors(Behaviors $behaviors)
|
||||
{
|
||||
$behaviors->add(new BoolCast([
|
||||
'active_checks_enabled',
|
||||
'passive_checks_enabled',
|
||||
'event_handler_enabled',
|
||||
'notifications_enabled',
|
||||
'flapping_enabled'
|
||||
]));
|
||||
}
|
||||
|
||||
public function createRelations(Relations $relations)
|
||||
{
|
||||
$relations->belongsTo('environment', Environment::class);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace Icinga\Module\Eagle\Model;
|
||||
|
||||
use Icinga\Module\Eagle\Model\Behavior\BoolCast;
|
||||
use ipl\Orm\Behaviors;
|
||||
use ipl\Orm\Model;
|
||||
use ipl\Orm\Relations;
|
||||
|
||||
|
|
@ -60,6 +62,17 @@ class Service extends Model
|
|||
];
|
||||
}
|
||||
|
||||
public function createBehaviors(Behaviors $behaviors)
|
||||
{
|
||||
$behaviors->add(new BoolCast([
|
||||
'active_checks_enabled',
|
||||
'passive_checks_enabled',
|
||||
'event_handler_enabled',
|
||||
'notifications_enabled',
|
||||
'flapping_enabled'
|
||||
]));
|
||||
}
|
||||
|
||||
public function createRelations(Relations $relations)
|
||||
{
|
||||
$relations->belongsTo('environment', Environment::class);
|
||||
|
|
|
|||
Loading…
Reference in a new issue