mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-28 08:14:03 +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,19 +259,23 @@ class Monitoring_ConfigController extends ModuleActionController
|
||||
$this->view->tabs = $this->Module()->getConfigTabs()->activate('security');
|
||||
|
||||
$form = new SecurityForm();
|
||||
$form->setConfiguration($this->Config()->get('security'));
|
||||
$request = $this->getRequest();
|
||||
if ($request->isPost() && $form->isValid($request->getPost())) {
|
||||
$config = $this->Config()->toArray();
|
||||
$config['security'] = $form->getConfig();
|
||||
if ($this->writeConfiguration(new Zend_Config($config))) {
|
||||
Notification::success('Configuration modified successfully');
|
||||
$this->redirectNow('monitoring/config/security');
|
||||
} else {
|
||||
$this->render('show-configuration');
|
||||
return;
|
||||
$config = $this->Config()->toArray();
|
||||
if ($request->isPost()) {
|
||||
if ($form->isValid($request->getPost())) {
|
||||
$config['security'] = $form->getValues();
|
||||
if ($this->writeConfiguration(new Zend_Config($config))) {
|
||||
Notification::success('Configuration modified successfully');
|
||||
$this->redirectNow('monitoring/config/security');
|
||||
} else {
|
||||
$this->render('show-configuration');
|
||||
return;
|
||||
}
|
||||
}
|
||||
} elseif (isset($config['security'])) {
|
||||
$form->populate($config['security']);
|
||||
}
|
||||
|
||||
$this->view->form = $form;
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
namespace Icinga\Module\Monitoring\Form\Config;
|
||||
|
||||
use Zend_Config;
|
||||
use Icinga\Web\Form;
|
||||
|
||||
/**
|
||||
@ -12,11 +11,6 @@ use Icinga\Web\Form;
|
||||
*/
|
||||
class SecurityForm extends Form
|
||||
{
|
||||
/**
|
||||
* The configuration to use for populating the form
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* Initialize this form
|
||||
*/
|
||||
@ -61,25 +55,4 @@ class SecurityForm extends Form
|
||||
|
||||
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