introduced configcontroller

This commit is contained in:
tracer 2022-09-17 16:26:14 +02:00
parent 4bff4182c8
commit d1325202ee
1 changed files with 10 additions and 4 deletions

View File

@ -1,4 +1,5 @@
<?php <?php
namespace App\Controller; namespace App\Controller;
error_reporting(error_level: E_ALL); error_reporting(error_level: E_ALL);
@ -21,13 +22,18 @@ class DatabaseConnection
const TABLE_APIKEYS = self::TABLE_PREFIX . "apikeys"; const TABLE_APIKEYS = self::TABLE_PREFIX . "apikeys";
const TABLE_DYNDNS = self::TABLE_PREFIX . "dyndns"; 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 // TODO create config => encryption key
try { try {
$this->dbConnection = new PDO( $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, username: $dbUser,
password: $dbPassword password: $dbPassword
); );