Skip to content

Commit 3254f5c

Browse files
committed
Fix: Review comments
1 parent 2c5cc2f commit 3254f5c

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

application/controllers/EventRuleController.php

+5-16
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,8 @@ public function indexAction(): void
4848
$ruleId = $this->params->getRequired('id');
4949

5050
$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'];
5453

5554
if ($this->getRequest()->isPost()) {
5655
if ($this->getRequest()->has('searchbar')) {
@@ -294,26 +293,16 @@ public function editAction(): void
294293
$eventRuleForm = (new EventRuleForm())
295294
->populate($config)
296295
->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) {
298297
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());
306299
$id = $db->lastInsertId();
307300

308301
$this->getResponse()->setHeader('X-Icinga-Container', 'col2');
309302
$this->sendExtraUpdates(['#col1']);
310303
$this->redirectNow(Links::eventRule($id));
311304
} 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]);
317306
$this->sendExtraUpdates([
318307
'#event-rule-form' => Url::fromPath(
319308
'notifications/event-rule/rule', ['id' => $ruleId]

0 commit comments

Comments
 (0)