// SPDX-License-Identifier: GPL-3.0-or-later namespace Icinga\Module\Setup\Steps; use Exception; use Icinga\Application\Logger; use Icinga\Application\Config; use Icinga\Exception\IcingaException; use Icinga\Module\Setup\Step; class GeneralConfigStep extends Step { protected $data; protected $error; public function __construct(array $data) { $this->data = $data; } public function apply() { $config = array(); foreach ($this->data['generalConfig'] as $sectionAndPropertyName => $value) { list($section, $property) = explode('_', $sectionAndPropertyName, 2); $config[$section][$property] = $value; } $config['global']['config_resource'] = $this->data['resourceName']; try { Config::fromArray($config) ->setConfigFile(Config::resolvePath('config.ini')) ->saveIni(); } catch (Exception $e) { $this->error = $e; return false; } $this->error = false; return true; } public function getSummary() { $pageTitle = '
' . mt('setup', 'Logging will be disabled.') . '
'; } else { $level = $this->data['generalConfig']['logging_level']; $typeDescription = null; $typeSpecificHtml = null; switch ($type) { case 'php': $typeDescription = t('Webserver Log', 'app.config.logging.type'); $typeSpecificHtml = ''; break; case 'syslog': $typeDescription = 'Syslog'; $typeSpecificHtml = '| ' . t('Type', 'app.config.logging') . ' | ' . '' . $typeDescription . ' | ' . '
| ' . t('Level', 'app.config.logging') . ' | ' . '' . ($level === Logger::$levels[Logger::ERROR] ? t('Error', 'app.config.logging.level') : ( $level === Logger::$levels[Logger::WARNING] ? t('Warning', 'app.config.logging.level') : ( $level === Logger::$levels[Logger::INFO] ? t('Information', 'app.config.logging.level') : ( t('Debug', 'app.config.logging.level') ) ) )) . ' | ' . '