Enable Discovery debug logging for production troubleshooting
- Add DISCOVERY_LOG_LEVEL=debug - Add DISCOVERY_SHOW_PROGRESS=true - Temporary changes for debugging InitializerProcessor fixes on production
This commit is contained in:
@@ -1,71 +1,110 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Framework\Filesystem;
|
||||
|
||||
use App\Framework\Core\ValueObjects\Byte;
|
||||
use App\Framework\Core\ValueObjects\Timestamp;
|
||||
|
||||
/**
|
||||
* Repräsentiert eine Datei im Dateisystem mit Lazy-Loading-Unterstützung.
|
||||
*
|
||||
* @property-read string $path Pfad zur Datei
|
||||
* @property-read Storage $storage Storage-Implementierung
|
||||
* @property-read string $contents Dateiinhalt (lazy geladen)
|
||||
* @property-read int $size Dateigröße in Bytes (lazy geladen)
|
||||
* @property-read int $lastModified Zeitstempel der letzten Änderung (lazy geladen)
|
||||
* Clean File value object representing a file path with metadata.
|
||||
* File operations are handled by FileSystemService for better separation of concerns.
|
||||
*/
|
||||
final readonly class File
|
||||
{
|
||||
public function __construct(
|
||||
public string $path,
|
||||
public Storage $storage,
|
||||
public string $contents = '',
|
||||
public int $size = 0,
|
||||
public int $lastModified = 0
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Prüft, ob die Datei existiert
|
||||
*/
|
||||
public function exists(): bool
|
||||
{
|
||||
return $this->storage->exists($this->path);
|
||||
public FilePath $path,
|
||||
public FileMetadata $metadata
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Löscht die Datei
|
||||
* Create File from SplFileInfo
|
||||
*/
|
||||
public function delete(): void
|
||||
public static function fromSplFileInfo(\SplFileInfo $fileInfo): self
|
||||
{
|
||||
$this->storage->delete($this->path);
|
||||
$path = FilePath::create($fileInfo->getPathname());
|
||||
$metadata = new FileMetadata(
|
||||
size: $fileInfo->getSize() ?: 0,
|
||||
lastModified: $fileInfo->getMTime() ?: 0,
|
||||
mimeType: 'application/octet-stream', // Default, can be determined by FileSystemService
|
||||
isReadable: $fileInfo->isReadable(),
|
||||
isWritable: $fileInfo->isWritable()
|
||||
);
|
||||
|
||||
return new self($path, $metadata);
|
||||
}
|
||||
|
||||
/**
|
||||
* Kopiert die Datei an einen neuen Ort
|
||||
* Get path as FilePath object
|
||||
*/
|
||||
public function copyTo(string $destination): File
|
||||
public function getPath(): FilePath
|
||||
{
|
||||
$this->storage->copy($this->path, $destination);
|
||||
return FilesystemFactory::createFile($destination, $this->storage);
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lädt die Dateieigenschaften neu
|
||||
* Get path as string
|
||||
*/
|
||||
public function refresh(): File
|
||||
public function getPathString(): string
|
||||
{
|
||||
return FilesystemFactory::createFile($this->path, $this->storage);
|
||||
return $this->path->toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Holt erweiterte Metadaten der Datei
|
||||
* Get file metadata
|
||||
*/
|
||||
public function getMetadata(): FileMetadata
|
||||
{
|
||||
return new FileMetadata(
|
||||
size: $this->size,
|
||||
lastModified: $this->lastModified,
|
||||
mimeType: $this->storage->getMimeType($this->path),
|
||||
isReadable: $this->storage->isReadable($this->path),
|
||||
isWritable: $this->storage->isWritable($this->path)
|
||||
);
|
||||
return $this->metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get modification time as Timestamp
|
||||
*/
|
||||
public function getModificationTime(): Timestamp
|
||||
{
|
||||
return Timestamp::fromFloat($this->metadata->lastModified);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get file size as Byte object
|
||||
*/
|
||||
public function getSize(): Byte
|
||||
{
|
||||
return Byte::fromBytes($this->metadata->size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get filename from path
|
||||
*/
|
||||
public function getFilename(): string
|
||||
{
|
||||
return $this->path->getFilename();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get file extension
|
||||
*/
|
||||
public function getExtension(): string
|
||||
{
|
||||
return $this->path->getExtension();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get directory path
|
||||
*/
|
||||
public function getDirectory(): FilePath
|
||||
{
|
||||
return $this->path->getDirectory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if file has specific extension
|
||||
*/
|
||||
public function hasExtension(string $extension): bool
|
||||
{
|
||||
return $this->path->hasExtension($extension);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user