@@ -48,9 +48,8 @@ public function indexAction(): void
48
48
$ ruleId = $ this ->params ->getRequired ('id ' );
49
49
50
50
$ eventRuleConfigValues = $ this ->fromDb ((int ) $ ruleId );
51
- $ filter = $ eventRuleConfigValues ['object_filter ' ]; // Assignment by reference to is used as search editor is a
52
- // different form and the config must have the updated
53
- // object_filter as soon as the search editor is closed
51
+
52
+ $ filter = $ eventRuleConfigValues ['object_filter ' ];
54
53
55
54
if ($ this ->getRequest ()->isPost ()) {
56
55
if ($ this ->getRequest ()->has ('searchbar ' )) {
@@ -294,26 +293,16 @@ public function editAction(): void
294
293
$ eventRuleForm = (new EventRuleForm ())
295
294
->populate ($ config )
296
295
->setAction (Url::fromRequest ()->getAbsoluteUrl ())
297
- ->on (Form::ON_SUCCESS , function ($ form ) use ($ ruleId , $ db ) {
296
+ ->on (Form::ON_SUCCESS , function (EventRuleForm $ form ) use ($ ruleId , $ db ) {
298
297
if ($ ruleId === '-1 ' ) {
299
- $ db ->insert ('rule ' , [
300
- 'name ' => $ form ->getValue ('name ' ),
301
- 'timeperiod_id ' => null ,
302
- 'object_filter ' => null ,
303
- 'is_active ' => $ form ->getValue ('is_active ' )
304
- ]);
305
-
298
+ $ db ->insert ('rule ' , $ form ->getValues ());
306
299
$ id = $ db ->lastInsertId ();
307
300
308
301
$ this ->getResponse ()->setHeader ('X-Icinga-Container ' , 'col2 ' );
309
302
$ this ->sendExtraUpdates (['#col1 ' ]);
310
303
$ this ->redirectNow (Links::eventRule ($ id ));
311
304
} else {
312
- $ db ->update ('rule ' , [
313
- 'name ' => $ form ->getValue ('name ' ),
314
- 'is_active ' => $ form ->getValue ('is_active ' )
315
- ], ['id = ? ' => $ ruleId ]);
316
-
305
+ $ db ->update ('rule ' , $ form ->getValues (), ['id = ? ' => $ ruleId ]);
317
306
$ this ->sendExtraUpdates ([
318
307
'#event-rule-form ' => Url::fromPath (
319
308
'notifications/event-rule/rule ' , ['id ' => $ ruleId ]
0 commit comments