blob: 0d64fbfe1f9fb9611c76a6a747668b637d3a18c7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
<?php
/* Icinga DB Web | (c) 2020 Icinga GmbH | GPLv2 */
namespace Icinga\Module\Icingadb\Controllers;
use Icinga\Application\Config;
use Icinga\Module\Icingadb\Forms\DatabaseConfigForm;
use Icinga\Module\Icingadb\Forms\RedisConfigForm;
use Icinga\Module\Icingadb\Web\Controller;
use Icinga\Web\Form;
use Icinga\Web\Widget\Tab;
use Icinga\Web\Widget\Tabs;
use ipl\Html\HtmlString;
class ConfigController extends Controller
{
// public function init()
// {
// $this->assertPermission('config/modules');
//
// parent::init();
// }
public function databaseAction()
{
$form = (new DatabaseConfigForm())
->setIniConfig(Config::module('icingadb'));
$form->handleRequest();
$this->mergeTabs($this->Module()->getConfigTabs()->activate('database'));
$this->addFormToContent($form);
}
public function redisAction()
{
$form = (new RedisConfigForm())
->setIniConfig($this->Config());
$form->handleRequest();
$this->mergeTabs($this->Module()->getConfigTabs()->activate('redis'));
$this->addFormToContent($form);
}
protected function addFormToContent(Form $form)
{
$this->addContent(new HtmlString($form->render()));
}
protected function mergeTabs(Tabs $tabs): self
{
/** @var Tab $tab */
foreach ($tabs->getTabs() as $tab) {
$this->tabs->add($tab->getName(), $tab);
}
return $this;
}
}
|