module change
This commit is contained in:
32
src/App/ModuleConfigException.php
Normal file
32
src/App/ModuleConfigException.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App;
|
||||
|
||||
final class ModuleConfigException extends \RuntimeException
|
||||
{
|
||||
private string $module;
|
||||
private ?string $details;
|
||||
|
||||
public function __construct(
|
||||
string $module,
|
||||
string $message,
|
||||
?string $details = null,
|
||||
int $code = 0,
|
||||
?\Throwable $previous = null
|
||||
) {
|
||||
parent::__construct($message, $code, $previous);
|
||||
$this->module = $module;
|
||||
$this->details = $details;
|
||||
}
|
||||
|
||||
public function module(): string
|
||||
{
|
||||
return $this->module;
|
||||
}
|
||||
|
||||
public function details(): ?string
|
||||
{
|
||||
return $this->details;
|
||||
}
|
||||
}
|
||||
@@ -113,7 +113,10 @@ final class ModuleManager
|
||||
$settings = $this->settings($name);
|
||||
$db = $settings['db'] ?? $fallback;
|
||||
if (!is_array($db) || empty($db)) {
|
||||
return null;
|
||||
throw new ModuleConfigException(
|
||||
$name,
|
||||
'Modul nicht konfiguriert. Bitte Setup ausfuehren.'
|
||||
);
|
||||
}
|
||||
|
||||
if (!isset($db['options'])) {
|
||||
@@ -123,15 +126,49 @@ final class ModuleManager
|
||||
];
|
||||
}
|
||||
|
||||
$pdo = Database::createFromArray($db);
|
||||
try {
|
||||
$pdo = Database::createFromArray($db);
|
||||
} catch (\Throwable $e) {
|
||||
if (defined('APP_DEBUG_TOOL') && APP_DEBUG_TOOL) {
|
||||
@file_put_contents(
|
||||
__DIR__ . '/../../debug/module_db_error.log',
|
||||
'[' . date('c') . '] ' . $name . ': ' . $e->getMessage() . PHP_EOL,
|
||||
FILE_APPEND
|
||||
);
|
||||
}
|
||||
throw new ModuleConfigException(
|
||||
$name,
|
||||
'Modul-Datenbank nicht korrekt konfiguriert.',
|
||||
$e->getMessage(),
|
||||
0,
|
||||
$e
|
||||
);
|
||||
}
|
||||
|
||||
if ($name === 'kea' && !empty($settings['kea_auto_init'])) {
|
||||
Database::ensureKeaSchema($pdo, [
|
||||
'auto_init' => true,
|
||||
'init_cmd' => $settings['kea_init_cmd'] ?? null,
|
||||
'init_script' => $settings['kea_init_script'] ?? null,
|
||||
'kea_db_version' => $settings['kea_db_version'] ?? '',
|
||||
]);
|
||||
try {
|
||||
Database::ensureKeaSchema($pdo, [
|
||||
'auto_init' => true,
|
||||
'init_cmd' => $settings['kea_init_cmd'] ?? null,
|
||||
'init_script' => $settings['kea_init_script'] ?? null,
|
||||
'kea_db_version' => $settings['kea_db_version'] ?? '',
|
||||
]);
|
||||
} catch (\Throwable $e) {
|
||||
if (defined('APP_DEBUG_TOOL') && APP_DEBUG_TOOL) {
|
||||
@file_put_contents(
|
||||
__DIR__ . '/../../debug/module_db_error.log',
|
||||
'[' . date('c') . '] ' . $name . ': ' . $e->getMessage() . PHP_EOL,
|
||||
FILE_APPEND
|
||||
);
|
||||
}
|
||||
throw new ModuleConfigException(
|
||||
$name,
|
||||
'Modul-Datenbank nicht korrekt konfiguriert.',
|
||||
$e->getMessage(),
|
||||
0,
|
||||
$e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $pdo;
|
||||
|
||||
Reference in New Issue
Block a user