mirror of
https://github.com/Icinga/icingadb-web.git
synced 2026-04-12 04:16:15 -04:00
Add SPDX license headers and mark source files as GPL-3.0-or-later to preserve the option to relicense under later GPL versions.
64 lines
1.5 KiB
PHP
64 lines
1.5 KiB
PHP
<?php
|
|
|
|
// SPDX-FileCopyrightText: 2019 Icinga GmbH <https://icinga.com>
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
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;
|
|
}
|
|
}
|