Globale Fußzeile mit Baukasten (0.38.0)
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 10m3s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 9m26s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 10m59s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 11m24s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 10m26s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 10m54s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 8m8s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 8m26s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 49s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m6s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Friederich Loheide 2026-09-27 15:59:26 +00:00
parent 6f59caa880
commit 8eb5d4a475
189 changed files with 1011 additions and 571 deletions

View file

@ -4,7 +4,7 @@ namespace App\Dashboard;
use App\Models\User;
use App\Pagebuilder\Content;
use App\Support\Audit;
use App\Pagebuilder\StoredDocument;
use App\Support\Settings;
use Illuminate\Support\Str;
@ -16,6 +16,8 @@ use Illuminate\Support\Str;
*/
class Homepage
{
use StoredDocument;
public const MODE = 'homepage.mode'; // widgets | builder
public const PUBLISHED = 'homepage.content';
@ -45,86 +47,17 @@ class Homepage
return $this->settings->get(self::MODE) === 'builder' ? 'builder' : 'widgets';
}
/**
* @return array{blocks: list<array<string, mixed>>}|null
*/
public function published(): ?array
protected function prefix(): string
{
$content = $this->settings->get(self::PUBLISHED);
return is_array($content) ? $content : null;
return 'homepage';
}
/**
* @return array{content: array<string, mixed>, updated_at: string, user: ?string}|null
*/
public function draft(): ?array
{
$draft = $this->settings->get(self::DRAFT);
return is_array($draft) && is_array($draft['content'] ?? null) ? $draft : null;
}
/**
* Arbeitsstand für den Editor: Entwurf, sonst veröffentlichter Stand, sonst die heutige Kachel-Anordnung.
*
* @return array{blocks: list<array<string, mixed>>}
*/
public function working(): array
protected function initial(): array
{
return $this->draft()['content'] ?? $this->published() ?? $this->fromWidgets();
}
/**
* @param array<mixed> $content
*/
public function saveDraft(array $content, User $user): void
{
$this->settings->set(self::DRAFT, ['content' => $this->content->sanitize($content), 'updated_at' => now()->toIso8601String(), 'user' => $user->name]);
}
public function discardDraft(): void
{
$this->settings->set(self::DRAFT, null);
}
public function publish(User $user): void
{
$content = $this->working();
$revisions = (array) $this->settings->get(self::REVISIONS, []);
array_unshift($revisions, ['id' => Str::random(8), 'content' => $content, 'at' => now()->toIso8601String(), 'user' => $user->name]);
$this->settings->setMany([
self::PUBLISHED => $content,
self::DRAFT => null,
self::REVISIONS => array_slice($revisions, 0, self::MAX_REVISIONS),
]);
Audit::log('homepage.published', ['blocks' => count($content['blocks'] ?? [])]);
}
/**
* @return list<array{id: string, at: string, user: ?string, blocks: int}>
*/
public function revisions(): array
{
return array_map(fn (array $r) => ['id' => $r['id'], 'at' => $r['at'], 'user' => $r['user'] ?? null, 'blocks' => count($r['content']['blocks'] ?? [])], (array) $this->settings->get(self::REVISIONS, []));
}
/**
* Frühere Fassung als Entwurf zurückholen.
*/
public function restore(string $id, User $user): bool
{
foreach ((array) $this->settings->get(self::REVISIONS, []) as $revision) {
if (($revision['id'] ?? null) === $id) {
$this->saveDraft($revision['content'], $user);
return true;
}
}
return false;
return $this->fromWidgets();
}
/**

View file

@ -0,0 +1,78 @@
<?php
namespace App\Filament\Pages;
use App\Filament\Clusters\HomepageCluster;
use App\Filament\Pages\Appearance\AppearanceFooter;
use App\Layout\Footer;
use App\Support\Audit;
use BackedEnum;
use Filament\Actions\Action;
use Filament\Notifications\Notification;
use Filament\Pages\Page;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Components\Text;
use Filament\Schemas\Schema;
use Filament\Support\Enums\FontWeight;
use Filament\Support\Icons\Heroicon;
/**
* Globale Fußzeile: Status und Einstieg in den Baukasten.
*/
class FooterSettings extends Page
{
protected string $view = 'filament.pages.schema-only';
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedBars3BottomLeft;
protected static ?string $cluster = HomepageCluster::class;
protected static ?int $navigationSort = 3;
protected static ?string $navigationLabel = 'Fußzeile';
protected static ?string $title = 'Fußzeile';
protected static ?string $slug = 'fusszeile';
public static function canAccess(): bool
{
return auth()->user()?->can('appearance.manage') ?? false;
}
public function form(Schema $schema): Schema
{
$footer = app(Footer::class);
$blocks = count($footer->published()['blocks'] ?? []);
return $schema->components([
Section::make('Gestaltete Fußzeile')->schema([
Text::make('Unter jeder Seite des Portals – frei gestaltet mit dem Baukasten: Spalten, Text, Links (Symbolliste), Bilder und alle Kacheln der Startseite. Jeder Block lässt sich auf Rollen, Abteilungen oder Standorte beschränken.'),
Text::make(match (true) {
$footer->isActive() => 'Stand: veröffentlicht ('.$blocks.' '.($blocks === 1 ? 'Block' : 'Blöcke').').'.($footer->draft() ? ' Es gibt einen unveröffentlichten Entwurf.' : ''),
$footer->draft() !== null => 'Stand: Entwurf, noch nicht veröffentlicht.',
default => 'Stand: noch nicht gestaltet – es erscheint nur die schmale Zeile mit Text und Links.',
})->weight(FontWeight::Bold),
]),
Section::make('Schmale Zeile ganz unten')->schema([
Text::make('Copyright-Text und Links wie „Impressum“ oder „Datenschutz“ pflegen Sie weiterhin unter „Erscheinungsbild → Fußzeile & E-Mails“. Sie stehen unter der gestalteten Fußzeile.'),
]),
]);
}
protected function getHeaderActions(): array
{
return [
Action::make('design')->label('Fußzeile gestalten')->icon(Heroicon::OutlinedPaintBrush)->url('/fusszeile/gestalten'),
Action::make('strip')->label('Text & Links')->icon(Heroicon::OutlinedLink)->color('gray')->url(fn () => AppearanceFooter::getUrl()),
Action::make('hide')->label('Ausblenden')->icon(Heroicon::OutlinedEyeSlash)->color('danger')
->visible(fn () => app(Footer::class)->isActive())
->requiresConfirmation()->modalDescription('Die gestaltete Fußzeile verschwindet aus dem Portal. Im Editor lässt sie sich unter „Frühere Fassungen“ wiederherstellen.')
->action(function () {
app(Footer::class)->unpublish();
Audit::log('footer.hidden');
Notification::make()->success()->title('Fußzeile ausgeblendet')->send();
}),
];
}
}

View file

@ -0,0 +1,140 @@
<?php
namespace App\Http\Controllers;
use App\Media\MediaLibrary;
use App\Pagebuilder\Blocks;
use App\Pagebuilder\Content;
use App\Support\Permissions\Audiences;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use Illuminate\Validation\Rules\File;
use Inertia\Inertia;
use Inertia\Response;
/**
* Gemeinsamer Editor für Baukasten-Inhalte aus den Einstellungen (Startseite, Fußzeile):
* Entwurf laufend speichern, veröffentlichen, frühere Fassungen zurückholen.
*/
abstract class BuilderDocumentController extends Controller
{
/** @return object Dokument mit App\Pagebuilder\StoredDocument */
abstract protected function document(): object;
/**
* Texte und Adressen für die Editor-Oberfläche.
*
* @return array<string, mixed>
*/
abstract protected function config(): array;
/** Kontext beim Rendern dynamischer Blöcke */
abstract protected function context(): array;
abstract protected function mediaFolder(): string;
public function edit(Request $request, Blocks $blocks): Response
{
$this->authorize($request);
$draft = $this->document()->draft();
return Inertia::render('HomepageEditor', [
'content' => $this->document()->working(),
'state' => $this->state(),
'revisions' => $this->document()->revisions(),
'blockTypes' => $blocks->forEditor(homepage: true),
'blockGroups' => Blocks::GROUPS,
'audienceOptions' => Audiences::options(),
'uploadsUrl' => rtrim(Storage::disk('uploads')->url(''), '/'),
'draftBy' => $draft['user'] ?? null,
'config' => $this->config(),
]);
}
public function saveDraft(Request $request): JsonResponse
{
$this->authorize($request);
$request->validate(['content' => ['present', 'array']]);
$this->document()->saveDraft($request->input('content'), $request->user());
return response()->json(['state' => $this->state()]);
}
public function discardDraft(Request $request): JsonResponse
{
$this->authorize($request);
$this->document()->discardDraft();
return response()->json(['state' => $this->state(), 'content' => $this->document()->working()]);
}
public function publish(Request $request): JsonResponse
{
$this->authorize($request);
$request->validate(['content' => ['nullable', 'array'], 'activate' => ['boolean']]);
if ($request->has('content')) {
$this->document()->saveDraft($request->input('content'), $request->user());
}
$this->document()->publish($request->user());
$this->published($request);
return response()->json(['state' => $this->state(), 'revisions' => $this->document()->revisions()]);
}
public function restore(Request $request, string $revision): JsonResponse
{
$this->authorize($request);
abort_unless($this->document()->restore($revision, $request->user()), 404);
return response()->json(['state' => $this->state(), 'content' => $this->document()->working()]);
}
public function preview(Request $request, Content $content): JsonResponse
{
$this->authorize($request);
$request->validate(['blocks' => ['required', 'array', 'max:100'], 'blocks.*' => ['array']]);
$props = [];
foreach ($request->input('blocks') as $block) {
if (is_string($block['id'] ?? null)) {
$props[$block['id']] = $content->preview($block, $request->user(), [...$this->context(), 'editing' => true]);
}
}
return response()->json(['props' => (object) $props]);
}
public function uploadImage(Request $request, MediaLibrary $library): JsonResponse
{
$this->authorize($request);
$request->validate(['image' => ['required', File::image()->types(['jpg', 'jpeg', 'png', 'webp', 'gif'])->max(15 * 1024)]]);
$media = $library->store($request->file('image'), $this->mediaFolder(), $request->user());
return response()->json(['path' => $media->path, 'url' => Blocks::imageUrl($media->path), 'media' => $media->toLibraryArray()]);
}
/** Nach dem Veröffentlichen (z. B. Startseite umschalten) */
protected function published(Request $request): void {}
/**
* @return array<string, mixed>
*/
protected function state(): array
{
return [
'has_draft' => $this->document()->draft() !== null,
'published' => $this->document()->published() !== null,
'draft_updated_at' => $this->document()->draft()['updated_at'] ?? null,
];
}
protected function authorize(Request $request): void
{
abort_unless($request->user()->can('appearance.manage'), 403);
}
}

View file

@ -0,0 +1,43 @@
<?php
namespace App\Http\Controllers;
use App\Layout\Footer;
/**
* Globale Fußzeile gestalten (Backend → Startseite & Menü → Fußzeile).
*/
class FooterEditorController extends BuilderDocumentController
{
public function __construct(private readonly Footer $footer) {}
protected function document(): Footer
{
return $this->footer;
}
protected function config(): array
{
return [
'kind' => 'footer',
'base' => '/fusszeile/gestalten',
'title' => 'Fußzeile gestalten',
'back' => '/admin/startseite-menue/fusszeile',
'preview' => '/?fusszeile=entwurf',
'media_label' => 'In der Fußzeile',
'empty' => 'Leere Fußzeile – rechts z. B. „Spalten“ wählen und darin Text, Symbolliste (Links) oder Kacheln einsetzen. Leer veröffentlicht, blendet sich die Fußzeile aus.',
'hint' => 'Die Fußzeile steht unter jeder Seite des Portals. Links lassen sich gut als „Symbolliste“ anlegen; Kacheln (z. B. Monatsspruch, Schnellzugriffe) stehen unter „Startseite“. Text und Links aus „Erscheinungsbild → Fußzeile“ bleiben als Zeile darunter.',
'initial' => 'Noch nicht veröffentlicht – ein Vorschlag mit drei Spalten',
];
}
protected function context(): array
{
return ['footer' => true];
}
protected function mediaFolder(): string
{
return 'pagebuilder/fusszeile';
}
}

View file

@ -3,125 +3,54 @@
namespace App\Http\Controllers;
use App\Dashboard\Homepage;
use App\Media\MediaLibrary;
use App\Pagebuilder\Blocks;
use App\Pagebuilder\Content;
use App\Support\Permissions\Audiences;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use Illuminate\Validation\Rules\File;
use Inertia\Inertia;
use Inertia\Response;
/**
* Frei gestaltete Startseite bearbeiten (erreichbar aus dem Backend unter „Startseite“).
*/
class HomepageEditorController extends Controller
class HomepageEditorController extends BuilderDocumentController
{
public function __construct(private readonly Homepage $homepage) {}
public function edit(Request $request, Blocks $blocks): Response
protected function document(): Homepage
{
$this->authorize($request);
$draft = $this->homepage->draft();
return Inertia::render('HomepageEditor', [
'content' => $this->homepage->working(),
'state' => $this->state(),
'revisions' => $this->homepage->revisions(),
'blockTypes' => $blocks->forEditor(homepage: true),
'blockGroups' => Blocks::GROUPS,
'audienceOptions' => Audiences::options(),
'uploadsUrl' => rtrim(Storage::disk('uploads')->url(''), '/'),
'draftBy' => $draft['user'] ?? null,
]);
return $this->homepage;
}
public function saveDraft(Request $request): JsonResponse
{
$this->authorize($request);
$request->validate(['content' => ['present', 'array']]);
$this->homepage->saveDraft($request->input('content'), $request->user());
return response()->json(['state' => $this->state()]);
}
public function discardDraft(Request $request): JsonResponse
{
$this->authorize($request);
$this->homepage->discardDraft();
return response()->json(['state' => $this->state(), 'content' => $this->homepage->working()]);
}
public function publish(Request $request): JsonResponse
{
$this->authorize($request);
$request->validate(['content' => ['nullable', 'array'], 'activate' => ['boolean']]);
if ($request->has('content')) {
$this->homepage->saveDraft($request->input('content'), $request->user());
}
$this->homepage->publish($request->user());
if ($request->boolean('activate')) {
$this->homepage->setMode('builder');
}
return response()->json(['state' => $this->state(), 'revisions' => $this->homepage->revisions()]);
}
public function restore(Request $request, string $revision): JsonResponse
{
$this->authorize($request);
abort_unless($this->homepage->restore($revision, $request->user()), 404);
return response()->json(['state' => $this->state(), 'content' => $this->homepage->working()]);
}
public function preview(Request $request, Content $content): JsonResponse
{
$this->authorize($request);
$request->validate(['blocks' => ['required', 'array', 'max:100'], 'blocks.*' => ['array']]);
$props = [];
foreach ($request->input('blocks') as $block) {
if (is_string($block['id'] ?? null)) {
$props[$block['id']] = $content->preview($block, $request->user(), ['homepage' => true, 'editing' => true]);
}
}
return response()->json(['props' => (object) $props]);
}
public function uploadImage(Request $request, MediaLibrary $library): JsonResponse
{
$this->authorize($request);
$request->validate(['image' => ['required', File::image()->types(['jpg', 'jpeg', 'png', 'webp', 'gif'])->max(15 * 1024)]]);
$media = $library->store($request->file('image'), 'pagebuilder/startseite', $request->user());
return response()->json(['path' => $media->path, 'url' => Blocks::imageUrl($media->path), 'media' => $media->toLibraryArray()]);
}
/**
* @return array{mode: string, has_draft: bool, published: bool, draft_updated_at: ?string}
*/
private function state(): array
protected function config(): array
{
return [
'mode' => $this->homepage->mode(),
'has_draft' => $this->homepage->draft() !== null,
'published' => $this->homepage->published() !== null,
'draft_updated_at' => $this->homepage->draft()['updated_at'] ?? null,
'kind' => 'homepage',
'base' => '/startseite/gestalten',
'title' => 'Startseite gestalten',
'back' => '/admin/startseite',
'preview' => '/?entwurf=1',
'media_label' => 'Auf der Startseite',
'empty' => 'Leere Startseite – rechts Blöcke wählen, z. B. „Spalten“ und darin „Neuigkeiten“ oder „Kachel“.',
'hint' => 'Unter „Startseite“ stehen alle Kacheln als Block bereit. Jeder Block lässt sich über „Sichtbarkeit“ auf Rollen, Abteilungen oder Standorte beschränken.',
'initial' => 'Noch nicht veröffentlicht – Ausgangspunkt ist die heutige Startseite',
];
}
private function authorize(Request $request): void
protected function context(): array
{
abort_unless($request->user()->can('appearance.manage'), 403);
return ['homepage' => true];
}
protected function mediaFolder(): string
{
return 'pagebuilder/startseite';
}
protected function published(Request $request): void
{
if ($request->boolean('activate')) {
$this->homepage->setMode('builder');
}
}
protected function state(): array
{
return [...parent::state(), 'mode' => $this->homepage->mode()];
}
}

View file

@ -2,11 +2,14 @@
namespace App\Http\Middleware;
use App\Layout\Footer;
use App\Models\User;
use App\Push\WebPush;
use App\Support\Branding;
use App\Support\Impersonation;
use App\Support\Navigation;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Middleware;
class HandleInertiaRequests extends Middleware
@ -28,6 +31,8 @@ class HandleInertiaRequests extends Middleware
return [
...parent::share($request),
'branding' => $this->branding->toArray(),
// Frei gestaltete Fußzeile – einmal geladen, dann im Browser behalten (bis zur nächsten Veröffentlichung)
'footerContent' => $user ? $this->footer($request, $user) : null,
'auth' => [
'user' => $user ? [
'id' => $user->id,
@ -53,4 +58,23 @@ class HandleInertiaRequests extends Middleware
],
];
}
private function footer(Request $request, User $user): mixed
{
$footer = app(Footer::class);
// Vorschau des Entwurfs aus dem Editor
if ($request->query('fusszeile') === 'entwurf' && $user->can('appearance.manage')) {
return $footer->render($user, draft: true);
}
if (! $footer->isActive()) {
return null;
}
// Schlüssel je Person und Fassung: nach „Veröffentlichen“ oder „Als Person anmelden“ neu laden
return Inertia::once(fn () => $footer->render($user))
->as('footer-'.substr(md5($footer->version().'|'.$user->id), 0, 12))
->until(600);
}
}

72
app/Layout/Footer.php Normal file
View file

@ -0,0 +1,72 @@
<?php
namespace App\Layout;
use App\Models\User;
use App\Pagebuilder\Content;
use App\Pagebuilder\StoredDocument;
use App\Support\Settings;
use Illuminate\Support\Str;
/**
* Globale Fußzeile auf allen Portalseiten – mit dem Seitenbaukasten frei gestaltet
* (Spalten, Text, Links, Kacheln …). Text und Links aus „Erscheinungsbild → Fußzeile“
* stehen weiterhin als schmale Zeile ganz unten.
*/
class Footer
{
use StoredDocument;
public const MAX_REVISIONS = 20;
public function __construct(private readonly Settings $settings, private readonly Content $content) {}
protected function prefix(): string
{
return 'footer';
}
/**
* Vorschlag für den Anfang: drei Spalten mit Überschrift und Text bzw. Links.
*
* @return array{blocks: list<array<string, mixed>>}
*/
protected function initial(): array
{
$column = fn (string $heading, array $block) => ['id' => Str::random(12), 'blocks' => [
['id' => Str::random(12), 'type' => 'heading', 'data' => ['text' => $heading, 'level' => '4']],
['id' => Str::random(12), ...$block],
]];
return $this->content->sanitize(['blocks' => [
['id' => Str::random(12), 'type' => 'columns', 'data' => ['layout' => '1-1-1', 'stack' => 'md', 'gap' => 'normal', 'align' => 'start'], 'items' => [
$column('Über uns', ['type' => 'text', 'data' => ['html' => '<p>Kurzer Text über Ihr Haus – Anschrift, Telefon, Leitbild.</p>']]),
$column('Schnell gefunden', ['type' => 'icon-list', 'data' => ['items' => [
['icon' => 'phone', 'title' => 'Telefonbuch', 'text' => '', 'url' => '/personen'],
['icon' => 'calendar-days', 'title' => 'Termine', 'text' => '', 'url' => '/termine'],
['icon' => 'file-text', 'title' => 'Impressum', 'text' => '', 'url' => '/seiten/impressum'],
]]]),
$column('Kontakt', ['type' => 'text', 'data' => ['html' => '<p>Zentrale: 0000 000000<br>info@example.org</p>']]),
]],
]]);
}
/** Gestaltete Fußzeile ausblenden – Versionen bleiben erhalten */
public function unpublish(): void
{
$this->settings->setMany(['footer.content' => null, 'footer.published_at' => now()->toIso8601String()]);
}
public function isActive(): bool
{
return ($this->published()['blocks'] ?? []) !== [];
}
/**
* @return array{blocks: list<array<string, mixed>>}
*/
public function render(User $user, bool $draft = false): array
{
return $this->content->render($draft ? $this->working() : ($this->published() ?? ['blocks' => []]), $user, ['footer' => true]);
}
}

View file

@ -0,0 +1,117 @@
<?php
namespace App\Pagebuilder;
use App\Models\User;
use App\Support\Audit;
use App\Support\Settings;
use Illuminate\Support\Str;
/**
* Baukasten-Inhalt, der in den Einstellungen liegt (Startseite, Fußzeile): veröffentlichter
* Stand, Entwurf und die letzten Versionen.
*
* @property-read Settings $settings
* @property-read Content $content
*/
trait StoredDocument
{
/** Schlüssel-Präfix in den Einstellungen, z. B. „homepage“ */
abstract protected function prefix(): string;
/**
* Ausgangspunkt, solange nichts veröffentlicht ist.
*
* @return array{blocks: list<array<string, mixed>>}
*/
abstract protected function initial(): array;
/**
* @return array{blocks: list<array<string, mixed>>}|null
*/
public function published(): ?array
{
$content = $this->settings->get($this->prefix().'.content');
return is_array($content) ? $content : null;
}
/**
* @return array{content: array<string, mixed>, updated_at: string, user: ?string}|null
*/
public function draft(): ?array
{
$draft = $this->settings->get($this->prefix().'.draft');
return is_array($draft) && is_array($draft['content'] ?? null) ? $draft : null;
}
/**
* Arbeitsstand für den Editor: Entwurf, sonst veröffentlichter Stand, sonst der Ausgangspunkt.
*
* @return array{blocks: list<array<string, mixed>>}
*/
public function working(): array
{
return $this->draft()['content'] ?? $this->published() ?? $this->initial();
}
/**
* @param array<mixed> $content
*/
public function saveDraft(array $content, User $user): void
{
$this->settings->set($this->prefix().'.draft', ['content' => $this->content->sanitize($content), 'updated_at' => now()->toIso8601String(), 'user' => $user->name]);
}
public function discardDraft(): void
{
$this->settings->set($this->prefix().'.draft', null);
}
public function publish(User $user): void
{
$content = $this->working();
$revisions = (array) $this->settings->get($this->prefix().'.revisions', []);
array_unshift($revisions, ['id' => Str::random(8), 'content' => $content, 'at' => now()->toIso8601String(), 'user' => $user->name]);
$this->settings->setMany([
$this->prefix().'.content' => $content,
$this->prefix().'.draft' => null,
$this->prefix().'.revisions' => array_slice($revisions, 0, self::MAX_REVISIONS),
$this->prefix().'.published_at' => now()->toIso8601String(),
]);
Audit::log($this->prefix().'.published', ['blocks' => count($content['blocks'] ?? [])]);
}
/** Wann zuletzt veröffentlicht – z. B. als Cache-Schlüssel */
public function version(): string
{
return (string) ($this->settings->get($this->prefix().'.published_at') ?? '0');
}
/**
* @return list<array{id: string, at: string, user: ?string, blocks: int}>
*/
public function revisions(): array
{
return array_map(fn (array $r) => ['id' => $r['id'], 'at' => $r['at'], 'user' => $r['user'] ?? null, 'blocks' => count($r['content']['blocks'] ?? [])], (array) $this->settings->get($this->prefix().'.revisions', []));
}
/**
* Frühere Fassung als Entwurf zurückholen.
*/
public function restore(string $id, User $user): bool
{
foreach ((array) $this->settings->get($this->prefix().'.revisions', []) as $revision) {
if (($revision['id'] ?? null) === $id) {
$this->saveDraft($revision['content'], $user);
return true;
}
}
return false;
}
}

View file

@ -9,5 +9,5 @@ namespace App;
*/
final class Version
{
public const VERSION = '0.37.0';
public const VERSION = '0.38.0';
}