mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-23 22:04:25 +02:00
Database: Read sql config from section [db]
of config.ini
Since the whole `resources.ini` should be stored in the db in the future, the main configuration of the icingaweb2 database is moved to the `config.ini`.
This commit is contained in:
parent
9eea738540
commit
acc2d2d852
@ -4,10 +4,9 @@
|
||||
namespace Icinga\Common;
|
||||
|
||||
use Icinga\Application\Config as IcingaConfig;
|
||||
use Icinga\Data\ResourceFactory;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
use ipl\Sql\Config as SqlConfig;
|
||||
use ipl\Sql\Connection;
|
||||
use LogicException;
|
||||
use PDO;
|
||||
|
||||
/**
|
||||
@ -25,12 +24,13 @@ trait Database
|
||||
protected function getDb()
|
||||
{
|
||||
if (! $this->hasDb()) {
|
||||
throw new LogicException('Please check if a db instance exists at all');
|
||||
throw new ConfigurationError('Cannot load resource config "db". Resource does not exist');
|
||||
}
|
||||
|
||||
$config = new SqlConfig(ResourceFactory::getResourceConfig(
|
||||
IcingaConfig::app()->get('global', 'config_resource')
|
||||
));
|
||||
$config = new SqlConfig(
|
||||
IcingaConfig::app()->getSection('db')
|
||||
);
|
||||
|
||||
if ($config->db === 'mysql') {
|
||||
$config->charset = 'utf8mb4';
|
||||
}
|
||||
@ -51,6 +51,6 @@ trait Database
|
||||
*/
|
||||
protected function hasDb()
|
||||
{
|
||||
return (bool) IcingaConfig::app()->get('global', 'config_resource');
|
||||
return ! IcingaConfig::app()->getSection('db')->isEmpty();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user