Öffne Katalog, Bibliothek und Testkauf für den MVP.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
463851d402
commit
fd6860efda
51 files changed
+2331
-31
No files matched your search
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\ContentVersionStatus;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class StoreContentFile implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function __construct(
|
||||
public readonly int $versionId,
|
||||
public readonly string $source,
|
||||
) {}
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
if (! str_starts_with($this->source, 'inhalte/') || str_contains($this->source, '..')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$version = ContentElementVersion::query()->find($this->versionId);
|
||||
|
||||
if ($version === null || $version->status !== ContentVersionStatus::Entwurf) {
|
||||
return;
|
||||
}
|
||||
|
||||
$name = basename($this->source);
|
||||
|
||||
if (preg_match('/^[A-Za-z0-9._-]+$/', $name) !== 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
$target = 'inhalte/'.$version->id.'/'.$name;
|
||||
$incoming = Storage::disk('cms_incoming');
|
||||
|
||||
if (! $incoming->exists($this->source)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Storage::disk('media_derived')->put($target, $incoming->get($this->source));
|
||||
|
||||
$metadata = $version->metadata ?? [];
|
||||
unset($metadata['incoming']);
|
||||
$metadata['file'] = $target;
|
||||
$version->metadata = $metadata;
|
||||
$version->content_hash = hash('sha256', json_encode([
|
||||
'body' => $version->body,
|
||||
'metadata' => $metadata,
|
||||
], JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE));
|
||||
$version->status = ContentVersionStatus::Bereit;
|
||||
$version->save();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user