Führe eine zentrale Widget-Registry mit visuellem Seiteneditor ein.
CI Feature / test (push) Successful in 31s
CI Feature / test (push) Successful in 31s
- Codebasiertes Widget-Register (config/cms.php) mit Vertrag
{id, type, v, variant, settings, data, refs}: Typkennung, Schemaversion,
Prüfregeln, freigegebene Varianten, Editorfelder, Blade-Ansicht,
Verweisauflösung und Medienliste je Widget-Art.
- Die sechs Bestandsbausteine bleiben als Version 1 lesbar; gespeicherte
Revisionen werden nicht umgeschrieben, sondern beim Lesen angehoben
(Bild und Text: Version 2 mit Titel, formatiertem Text, Bild links/rechts).
Wiederherstellen kopiert eine Revision unverändert.
- Neue Widgets: Einstieg (Hero) und Programm-/Modulkarten. Letztere speichern
nur Verweise; Titel und Kurzbeschreibung kommen aus den Fachdaten. Öffentlich
erscheinen nur Programme mit Anzeigefreigabe (gleiche Regel wie /programme,
jetzt in PublicCatalogReader); Module nur in der Redaktionsvorschau, bis
öffentliche Profile (ADR-29) bestehen.
- Ein Renderer für öffentliche Seite, Vorschau und Blockvorschau im Editor.
- Seiteneditor als Filament-Builder: Auswahl mit Beschreibung und Schema,
kompakte Abschnitte mit Vorschau, Bearbeitung im Dialog, Sortieren,
Duplizieren. Speichern erzeugt nur einen Entwurf.
- Vorschau einer Revision in 390/768/1440 px; Vorschauroute nutzt den
Personal-Guard (vorher war sie für Redakteure ohne Mitgliedersitzung
nicht erreichbar).
- Basislayout in Komponenten (Marke, Kopf, Fuß, Seitenvorlage).
- Navigation: bearbeiten, ausblenden, löschen, per Ziehen sortieren;
unsichere Adressen (javascript:) werden abgewiesen und nicht ausgegeben.
Ergänzende Migration is_visible (Vorgabe sichtbar).
- Pfadfehler und doppelte Pfade erscheinen am Pfadfeld statt still zu scheitern.
Tests: BlockRegistryTest geht in WidgetRegistryTest auf (gleiche Prüfungen
plus Registrierung, Versionierung, Bereinigung). Bestandsseiten werden gegen
Textfixtures aus dem Stand vor der Umstellung geprüft.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cfdd6de0c7
commit
9d936bfa4a
76 files changed
+4237
-475
No files matched your search
@@ -2,36 +2,23 @@
|
||||
|
||||
namespace App\Domain\Cms;
|
||||
|
||||
use App\Domain\Cms\Blocks\BlockRegistry;
|
||||
use App\Domain\Cms\Widgets\WidgetRegistry;
|
||||
use App\Jobs\PublishPublicMedia;
|
||||
use App\Models\User;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class PageService
|
||||
{
|
||||
public function __construct(private readonly BlockRegistry $blocks) {}
|
||||
public function __construct(private readonly WidgetRegistry $widgets) {}
|
||||
|
||||
/**
|
||||
* @param list<array<string, mixed>> $blocks
|
||||
* Speichert einen Entwurf als neue Revision. Veröffentlicht nichts.
|
||||
*
|
||||
* @param array<int|string, mixed> $blocks Bausteine im Altformat oder als Widget-Hülle
|
||||
*/
|
||||
public function saveRevision(Page $page, array $blocks, ?string $seoTitle, ?string $seoDescription, ?User $author): PageRevision
|
||||
{
|
||||
$normalized = $this->blocks->normalize($blocks);
|
||||
|
||||
$revision = $page->revisions()->create([
|
||||
'blocks' => $normalized,
|
||||
'seo_title' => $seoTitle !== null && $seoTitle !== '' ? $seoTitle : null,
|
||||
'seo_description' => $seoDescription !== null && $seoDescription !== '' ? $seoDescription : null,
|
||||
'created_by' => $author?->id,
|
||||
]);
|
||||
|
||||
foreach ($normalized as $block) {
|
||||
if (($block['type'] ?? null) === 'image_text' && filled($block['image'] ?? null)) {
|
||||
PublishPublicMedia::dispatch($block['image']);
|
||||
}
|
||||
}
|
||||
|
||||
return $revision;
|
||||
return $this->storeRevision($page, $this->widgets->normalize($blocks), $seoTitle, $seoDescription, $author);
|
||||
}
|
||||
|
||||
public function publish(Page $page, PageRevision $revision): void
|
||||
@@ -46,6 +33,10 @@ public function publish(Page $page, PageRevision $revision): void
|
||||
$page->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Legt den Stand einer früheren Revision unverändert als neue Revision an. Die gespeicherten Bausteine
|
||||
* werden nicht umgeschrieben; ältere Formate werden erst beim Lesen angehoben.
|
||||
*/
|
||||
public function restore(Page $page, PageRevision $source, ?User $author): PageRevision
|
||||
{
|
||||
if ($source->page_id !== $page->id) {
|
||||
@@ -54,15 +45,36 @@ public function restore(Page $page, PageRevision $source, ?User $author): PageRe
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->saveRevision(
|
||||
return $this->storeRevision(
|
||||
$page,
|
||||
$source->blocks,
|
||||
$source->blocks ?? [],
|
||||
$source->seo_title,
|
||||
$source->seo_description,
|
||||
$author,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalisiert den Pfad und prüft, dass keine andere Seite ihn verwendet.
|
||||
*/
|
||||
public function availablePath(string $path, ?Page $except = null): string
|
||||
{
|
||||
$path = $this->normalizePath($path);
|
||||
|
||||
$taken = Page::query()
|
||||
->where('path', $path)
|
||||
->when($except !== null, fn ($query) => $query->whereKeyNot($except->getKey()))
|
||||
->exists();
|
||||
|
||||
if ($taken) {
|
||||
throw ValidationException::withMessages([
|
||||
'path' => 'Diesen Pfad verwendet bereits eine andere Seite.',
|
||||
]);
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
public function normalizePath(string $path): string
|
||||
{
|
||||
$path = '/'.trim($path, '/');
|
||||
@@ -81,4 +93,23 @@ public function normalizePath(string $path): string
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $blocks
|
||||
*/
|
||||
private function storeRevision(Page $page, array $blocks, ?string $seoTitle, ?string $seoDescription, ?User $author): PageRevision
|
||||
{
|
||||
$revision = $page->revisions()->create([
|
||||
'blocks' => array_values($blocks),
|
||||
'seo_title' => $seoTitle !== null && $seoTitle !== '' ? $seoTitle : null,
|
||||
'seo_description' => $seoDescription !== null && $seoDescription !== '' ? $seoDescription : null,
|
||||
'created_by' => $author?->id,
|
||||
]);
|
||||
|
||||
foreach ($this->widgets->mediaPaths($revision->blocks) as $path) {
|
||||
PublishPublicMedia::dispatch($path);
|
||||
}
|
||||
|
||||
return $revision;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user