Lasse Präsentationsmedien ohne Inhaltsfassung zu.
CI Feature / test (push) Successful in 53s
Deploy Test / test (push) Successful in 48s
Deploy Test / deploy (push) Successful in 22s

Bilder, Filme und Hörstücke lassen sich zuordnen und für die Website freigeben, ohne eine fachliche Fassung anzulegen. Unterrichtsfilme behalten die Teaserfassung an ihrer bereitgestellten Fassung.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-11-19 08:20:35 +01:00
1 parent 5590225f4f
commit 7b325f0d66
25 files changed
+734 -93

No files matched your search

+71
View File
@@ -0,0 +1,71 @@
<?php
namespace App\Domain\Media;
use App\Domain\Catalog\ContentElement;
use App\Domain\Catalog\DomainRuleException;
use Illuminate\Support\Facades\Storage;
/**
* Legt die technische Ableitung eines Präsentationsmediums an der Medienidentität ab.
* Es entsteht keine Inhaltsfassung, keine Freigabe und keine Berechtigung.
*/
class PresentationFile
{
public function store(ContentElement $element, string $incoming): void
{
if (! in_array($element->output_class, ['bild', 'film', 'audio'], true)) {
throw new DomainRuleException('Eine Präsentationsdatei ist ein Bild, ein Film oder ein Hörstück.');
}
if ($element->versions()->exists()) {
throw new DomainRuleException('Dieses Medium hat bereits eine Inhaltsfassung. Die Präsentationsdatei ersetzt sie nicht.');
}
if (! $this->readable($incoming)) {
throw new DomainRuleException('Die Datei liegt nicht im Eingang.');
}
$extension = strtolower(pathinfo($incoming, PATHINFO_EXTENSION));
$allowed = match ($element->output_class) {
'bild' => ['jpg', 'jpeg', 'png', 'webp', 'gif'],
'audio' => ['mp3', 'm4a', 'ogg'],
default => ['mp4', 'webm'],
};
if (! in_array($extension, $allowed, true)) {
throw new DomainRuleException('Diese Datei ist keine freigebbare Ableitung. Es wird keine Inhaltsfassung angelegt.');
}
$prefix = $element->output_class === 'bild' ? 'vorschau' : 'teaser';
$target = $prefix.'/'.$element->id.'/datei.'.$extension;
$stream = Storage::disk('cms_incoming')->readStream($incoming);
if (! is_resource($stream)) {
throw new DomainRuleException('Die Datei ließ sich nicht lesen.');
}
try {
Storage::disk('media_derived')->writeStream($target, $stream);
} finally {
fclose($stream);
}
if ($element->output_class === 'bild') {
$element->thumbnail_path = $target;
$element->thumbnail_source = 'eigen';
} else {
$element->preview_path = $target;
}
$element->save();
}
private function readable(string $path): bool
{
return (str_starts_with($path, 'inhalte/') || str_starts_with($path, 'cms/') || str_starts_with($path, 'vorschau/'))
&& ! str_contains($path, '..')
&& preg_match('#^(inhalte|cms|vorschau)/[A-Za-z0-9._\-/]+$#', $path) === 1
&& Storage::disk('cms_incoming')->exists($path);
}
}