mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-28 16:24:04 +02:00
Avoid NIH
It's useless to have specific getters and setters if generic methods from the baseclass can be used as well to accomplish the same task. refs #6641
This commit is contained in:
parent
a0b2c0b454
commit
5028ec7b0b
@ -259,11 +259,11 @@ class Monitoring_ConfigController extends ModuleActionController
|
|||||||
$this->view->tabs = $this->Module()->getConfigTabs()->activate('security');
|
$this->view->tabs = $this->Module()->getConfigTabs()->activate('security');
|
||||||
|
|
||||||
$form = new SecurityForm();
|
$form = new SecurityForm();
|
||||||
$form->setConfiguration($this->Config()->get('security'));
|
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
if ($request->isPost() && $form->isValid($request->getPost())) {
|
|
||||||
$config = $this->Config()->toArray();
|
$config = $this->Config()->toArray();
|
||||||
$config['security'] = $form->getConfig();
|
if ($request->isPost()) {
|
||||||
|
if ($form->isValid($request->getPost())) {
|
||||||
|
$config['security'] = $form->getValues();
|
||||||
if ($this->writeConfiguration(new Zend_Config($config))) {
|
if ($this->writeConfiguration(new Zend_Config($config))) {
|
||||||
Notification::success('Configuration modified successfully');
|
Notification::success('Configuration modified successfully');
|
||||||
$this->redirectNow('monitoring/config/security');
|
$this->redirectNow('monitoring/config/security');
|
||||||
@ -272,6 +272,10 @@ class Monitoring_ConfigController extends ModuleActionController
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} elseif (isset($config['security'])) {
|
||||||
|
$form->populate($config['security']);
|
||||||
|
}
|
||||||
|
|
||||||
$this->view->form = $form;
|
$this->view->form = $form;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
namespace Icinga\Module\Monitoring\Form\Config;
|
namespace Icinga\Module\Monitoring\Form\Config;
|
||||||
|
|
||||||
use Zend_Config;
|
|
||||||
use Icinga\Web\Form;
|
use Icinga\Web\Form;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -12,11 +11,6 @@ use Icinga\Web\Form;
|
|||||||
*/
|
*/
|
||||||
class SecurityForm extends Form
|
class SecurityForm extends Form
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* The configuration to use for populating the form
|
|
||||||
*/
|
|
||||||
protected $config;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize this form
|
* Initialize this form
|
||||||
*/
|
*/
|
||||||
@ -61,25 +55,4 @@ class SecurityForm extends Form
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the configuration to be used for initial population of the form
|
|
||||||
*/
|
|
||||||
public function setConfiguration($config)
|
|
||||||
{
|
|
||||||
$this->config = $config;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the configuration set by this form
|
|
||||||
*
|
|
||||||
* @return Zend_Config The configuration set in this form
|
|
||||||
*/
|
|
||||||
public function getConfig()
|
|
||||||
{
|
|
||||||
$values = $this->getValues();
|
|
||||||
return new Zend_Config(array(
|
|
||||||
'protected_customvars' => $values['protected_customvars']
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user