introduced configcontroller
This commit is contained in:
parent
4bff4182c8
commit
d1325202ee
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
error_reporting(error_level: E_ALL);
|
||||
|
@ -21,13 +22,18 @@ class DatabaseConnection
|
|||
const TABLE_APIKEYS = self::TABLE_PREFIX . "apikeys";
|
||||
const TABLE_DYNDNS = self::TABLE_PREFIX . "dyndns";
|
||||
|
||||
public function __construct(private array $config)
|
||||
public function __construct(private readonly ConfigController $configController)
|
||||
{
|
||||
extract(array: $this->config);
|
||||
$dbHost = $this->configController->getConfig(configKey: 'dbHost');
|
||||
$dbPort = $this->configController->getConfig(configKey: 'dbPort');
|
||||
$dbDatabase = $this->configController->getConfig(configKey: 'dbDatabase');
|
||||
$dbUser = $this->configController->getConfig(configKey: 'dbUser');
|
||||
$dbPassword = $this->configController->getConfig(configKey: 'dbPassword');
|
||||
|
||||
// TODO create config => encryption key
|
||||
try {
|
||||
$this->dbConnection = new PDO(
|
||||
dsn: "mysql:host=$dbHost;port=$dbPort;charset=utf8mb4;dbname=$dbDatabase",
|
||||
dsn : "mysql:host=$dbHost;port=$dbPort;charset=utf8mb4;dbname=$dbDatabase",
|
||||
username: $dbUser,
|
||||
password: $dbPassword
|
||||
);
|
||||
|
@ -101,7 +107,7 @@ class DatabaseConnection
|
|||
}
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
} catch (PDOException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
echo 'Did you create the database and adjust the config file?' . PHP_EOL;
|
||||
|
|
Loading…
Reference in New Issue