diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 12:36:40 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 12:36:40 +0000 |
commit | a0901c4b7f2db488cb4fb3be2dd921a0308f4659 (patch) | |
tree | fafb393cf330a60df129ff10d0059eb7b14052a7 /application/controllers/ConfigController.php | |
parent | Initial commit. (diff) | |
download | icingadb-web-a0901c4b7f2db488cb4fb3be2dd921a0308f4659.tar.xz icingadb-web-a0901c4b7f2db488cb4fb3be2dd921a0308f4659.zip |
Adding upstream version 1.0.2.upstream/1.0.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'application/controllers/ConfigController.php')
-rw-r--r-- | application/controllers/ConfigController.php | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/application/controllers/ConfigController.php b/application/controllers/ConfigController.php new file mode 100644 index 0000000..0d64fbf --- /dev/null +++ b/application/controllers/ConfigController.php @@ -0,0 +1,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; + } +} |