refactor(console, id, config): Dialog mode in Console, consolidated id modul, added config support for ini directives

This commit is contained in:
2025-11-04 13:44:27 +01:00
parent 980714f656
commit bfce93ce77
110 changed files with 2828 additions and 774 deletions

View File

@@ -5,8 +5,7 @@ declare(strict_types=1);
namespace App\Framework\Filesystem;
use App\Framework\Filesystem\ValueObjects\FilePath;
use App\Framework\Logging\DefaultLogger;
use App\Framework\Logging\LoggerFactory;
use App\Framework\Logging\Logger;
use ReflectionClass;
/**
@@ -14,6 +13,22 @@ use ReflectionClass;
*/
final readonly class FilesystemFactory
{
public function __construct(
private ?Logger $logger = null
) {
}
/**
* Erstellt eine neue FilesystemFactory-Instanz mit Logger.
*
* @param Logger|null $logger Optional logger instance
* @return self
*/
public static function create(?Logger $logger = null): self
{
return new self($logger);
}
/**
* Erstellt ein File-Objekt mit Lazy-Loading für schwere Eigenschaften.
*
@@ -21,21 +36,18 @@ final readonly class FilesystemFactory
* @param Storage $storage Storage-Implementierung
* @param int|null $cacheTimeoutSeconds Optional, Zeit in Sekunden, nach der der Cache ungültig wird
* @param bool $lazyLoad Optional, ob Lazy-Loading verwendet werden soll
* @param DefaultLogger|null $logger Optional, Logger für Debug-Informationen
*/
public static function createFile(
public function createFile(
FilePath|string $path,
Storage $storage,
?int $cacheTimeoutSeconds = null,
bool $lazyLoad = true,
?DefaultLogger $logger = null
bool $lazyLoad = true
): File {
$logger ??= LoggerFactory::getDefaultLogger();
$pathString = $path instanceof FilePath ? $path->toString() : $path;
// Direkte Instanziierung ohne Lazy-Loading
if (! $lazyLoad) {
$logger->debug("Erstelle File-Objekt ohne Lazy-Loading: {$pathString}");
$this->logger?->debug("Erstelle File-Objekt ohne Lazy-Loading: {$pathString}");
// Nur laden wenn die Datei existiert
if (! $storage->exists($pathString)) {
@@ -53,21 +65,22 @@ final readonly class FilesystemFactory
$reflection = new ReflectionClass(File::class);
$loadTime = time();
$logger = $this->logger;
// LazyProxy verwenden für individuelle Property-Callbacks
return $reflection->newLazyProxy([
// Dateiinhalt wird erst beim ersten Zugriff geladen
'contents' => function (File $file) use ($loadTime, $cacheTimeoutSeconds, $logger) {
$pathStr = $file->getPathString();
$logger->debug("Lazy-Loading contents für {$pathStr}");
$logger?->debug("Lazy-Loading contents für {$pathStr}");
// Cache-Invalidierung basierend auf Zeit
if ($cacheTimeoutSeconds !== null && time() - $loadTime > $cacheTimeoutSeconds) {
$logger->debug("Cache-Timeout erreicht für {$pathStr}, lade neu");
$logger?->debug("Cache-Timeout erreicht für {$pathStr}, lade neu");
}
if (! $file->exists()) {
$logger->debug("Datei existiert nicht: {$pathStr}");
$logger?->debug("Datei existiert nicht: {$pathStr}");
return '';
}
@@ -78,15 +91,15 @@ final readonly class FilesystemFactory
// Dateigröße wird erst beim ersten Zugriff ermittelt
'size' => function (File $file) use ($loadTime, $cacheTimeoutSeconds, $logger) {
$pathStr = $file->getPathString();
$logger->debug("Lazy-Loading size für {$pathStr}");
$logger?->debug("Lazy-Loading size für {$pathStr}");
// Cache-Invalidierung basierend auf Zeit
if ($cacheTimeoutSeconds !== null && time() - $loadTime > $cacheTimeoutSeconds) {
$logger->debug("Cache-Timeout erreicht für {$pathStr}, lade neu");
$logger?->debug("Cache-Timeout erreicht für {$pathStr}, lade neu");
}
if (! $file->exists()) {
$logger->debug("Datei existiert nicht: {$pathStr}");
$logger?->debug("Datei existiert nicht: {$pathStr}");
return 0;
}
@@ -97,15 +110,15 @@ final readonly class FilesystemFactory
// Zeitstempel wird erst beim ersten Zugriff ermittelt
'lastModified' => function (File $file) use ($loadTime, $cacheTimeoutSeconds, $logger) {
$pathStr = $file->getPathString();
$logger->debug("Lazy-Loading lastModified für {$pathStr}");
$logger?->debug("Lazy-Loading lastModified für {$pathStr}");
// Cache-Invalidierung basierend auf Zeit
if ($cacheTimeoutSeconds !== null && time() - $loadTime > $cacheTimeoutSeconds) {
$logger->debug("Cache-Timeout erreicht für {$pathStr}, lade neu");
$logger?->debug("Cache-Timeout erreicht für {$pathStr}, lade neu");
}
if (! $file->exists()) {
$logger->debug("Datei existiert nicht: {$pathStr}");
$logger?->debug("Datei existiert nicht: {$pathStr}");
return 0;
}
@@ -121,20 +134,17 @@ final readonly class FilesystemFactory
* @param FilePath|string $path Pfad zum Verzeichnis
* @param Storage $storage Storage-Implementierung
* @param bool $lazyLoad Optional, ob Lazy-Loading verwendet werden soll
* @param DefaultLogger|null $logger Optional, Logger für Debug-Informationen
*/
public static function createDirectory(
public function createDirectory(
FilePath|string $path,
Storage $storage,
bool $lazyLoad = true,
?DefaultLogger $logger = null
bool $lazyLoad = true
): Directory {
$logger ??= LoggerFactory::getDefaultLogger();
$pathString = $path instanceof FilePath ? $path->toString() : $path;
// Direkte Instanziierung ohne Lazy-Loading
if (! $lazyLoad) {
$logger->debug("Erstelle Directory-Objekt ohne Lazy-Loading: {$pathString}");
$this->logger?->debug("Erstelle Directory-Objekt ohne Lazy-Loading: {$pathString}");
$contents = [];
if (is_dir($pathString)) {
@@ -145,13 +155,14 @@ final readonly class FilesystemFactory
}
$reflection = new ReflectionClass(Directory::class);
$logger = $this->logger;
// LazyGhost verwenden - alle Eigenschaften werden beim ersten Zugriff initialisiert
$lazyDir = $reflection->newLazyGhost(
// Initializer-Callback
function (Directory $directory) use ($logger): void {
$pathStr = $directory->getPathString();
$logger->debug("Lazy-Loading Directory-Inhalt für {$pathStr}");
$logger?->debug("Lazy-Loading Directory-Inhalt für {$pathStr}");
// Verzeichnisinhalt wird erst beim ersten Zugriff auf eine Eigenschaft geladen
if ($directory->exists()) {