icingaweb2-module-businessp.../application/controllers/ConfigController.php
jrauh01 c552b1db7b
Allow to configure number of shown menu items (#484)
This PR adds a **General** config tab with an option to set the number of items
shown in the sidebar menu. Previously, this was a fixed number of **five**. That
value is now kept as the default if none is provided.
2026-03-25 12:38:18 +01:00

54 lines
1.5 KiB
PHP

<?php
// SPDX-FileCopyrightText: 2026 Icinga GmbH <https://icinga.com>
// SPDX-License-Identifier: GPL-3.0-or-later
namespace Icinga\Module\Businessprocess\Controllers;
use Icinga\Application\Config;
use Icinga\Module\Businessprocess\Forms\GeneralConfigForm;
use Icinga\Web\Notification;
use Icinga\Web\Widget\Tabs;
use ipl\Html\Contract\Form;
use ipl\Web\Compat\CompatController;
class ConfigController extends CompatController
{
public function init(): void
{
$this->assertPermission('config/modules');
parent::init();
}
public function generalAction(): void
{
$this->mergeTabs($this->Module()->getConfigTabs()->activate('general'));
$config = Config::module('businessprocess');
$form = (new GeneralConfigForm())
->populate($config->getSection('general'))
->on(Form::ON_SUBMIT, function (GeneralConfigForm $form) use ($config) {
$config->setSection('general', $form->getValues());
$config->saveIni();
Notification::success($this->translate('New configuration saved successfully'));
})->handleRequest($this->getServerRequest());
$this->addContent($form);
}
/**
* Merge tabs with other tabs contained in this tab panel
*
* @param Tabs $tabs
*
* @return void
*/
protected function mergeTabs(Tabs $tabs): void
{
foreach ($tabs->getTabs() as $tab) {
$this->tabs->add($tab->getName(), $tab);
}
}
}