From 88ccf149075cc338f324ca9e86fe7963b20063d9 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 11 Oct 2019 15:55:14 +0200 Subject: [PATCH] Host/Service: Transform y|n enums to true|false --- library/Eagle/Model/Behavior/BoolCast.php | 11 +++++++++++ library/Eagle/Model/Host.php | 13 +++++++++++++ library/Eagle/Model/Service.php | 13 +++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 library/Eagle/Model/Behavior/BoolCast.php diff --git a/library/Eagle/Model/Behavior/BoolCast.php b/library/Eagle/Model/Behavior/BoolCast.php new file mode 100644 index 00000000..1869300d --- /dev/null +++ b/library/Eagle/Model/Behavior/BoolCast.php @@ -0,0 +1,11 @@ +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); diff --git a/library/Eagle/Model/Service.php b/library/Eagle/Model/Service.php index 34c96140..630cf685 100644 --- a/library/Eagle/Model/Service.php +++ b/library/Eagle/Model/Service.php @@ -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);