[icinga-checkins] icinga.org: icingaweb2/feature/announce-banner-11198: Simplify Announce creation
git at icinga.org
git at icinga.org
Wed Nov 2 12:55:26 CET 2016
Module: icingaweb2
Branch: feature/announce-banner-11198
Commit: 4e7647fb6c01025fbe165b3d5a16c079ecc66b24
URL: https://git.icinga.org/?p=icingaweb2.git;a=commit;h=4e7647fb6c01025fbe165b3d5a16c079ecc66b24
Author: Alexander A. Klimov <alexander.klimov at icinga.com>
Date: Wed Nov 2 12:54:45 2016 +0100
Simplify Announce creation
refs #11198
---
library/Icinga/Repository/AnnounceIniRepository.php | 7 ++-----
library/Icinga/Web/Announce.php | 4 +++-
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/library/Icinga/Repository/AnnounceIniRepository.php b/library/Icinga/Repository/AnnounceIniRepository.php
index 8f1abed..0c3bb32 100644
--- a/library/Icinga/Repository/AnnounceIniRepository.php
+++ b/library/Icinga/Repository/AnnounceIniRepository.php
@@ -83,7 +83,7 @@ class AnnounceIniRepository extends IniRepository
$new->id = uniqid('', true);
}
if (! isset($new->hash)) {
- $announce = new Announce($new);
+ $announce = new Announce((array) $new);
$new->hash = $announce->getHash();
}
@@ -101,10 +101,7 @@ class AnnounceIniRepository extends IniRepository
protected function onUpdateAnnounce($old, $new)
{
if ($new->message !== $old->message) {
- $options = (array) $new;
- unset($options['id']);
- unset($options['hash']);
- $announce = new Announce($options);
+ $announce = new Announce((array) $new);
$new->hash = $announce->getHash();
}
diff --git a/library/Icinga/Web/Announce.php b/library/Icinga/Web/Announce.php
index f5b52b9..ad03871 100644
--- a/library/Icinga/Web/Announce.php
+++ b/library/Icinga/Web/Announce.php
@@ -46,7 +46,9 @@ class Announce
{
foreach ($properties as $k => $v) {
$method = 'set' . ucfirst($k);
- $this->$method($v);
+ if (method_exists($this, $method)) {
+ $this->$method($v);
+ }
}
}
More information about the icinga-checkins
mailing list