CI Feature / test (push) Failing after 20s
- Seite → Abschnitte → Plätze → Widgets: sechs Raster mit höchstens vier Einheiten, Hintergrund, Breite, Abstand und Trenner als Aufzählungswerte; je Platz ein Widget aus dem bestehenden Register. Neue Spalte page_revisions.sections (ergänzend); blocks erhält weiterhin alle Widgets in Lesereihenfolge als Rollback-Fassung. - Widgets erhalten Mindest- und Vorzugsbreite; Darstellung über Container-Abfragen. - Editor: Abschnitts-Repeater mit grafischer Rasterauswahl, Plätzen im Rasterverhältnis, breiter Arbeitsfläche, kompakten Vorschauen ohne Bildlaufleiste, Meldungen mit Abschnitt und Platz; Rasterwechsel entfernt nie ein Widget. Seite duplizieren. - Designsystem: Marken- und Bedeutungs-Tokens (vorläufig), gemeinsame Grundkomponenten, Nunito/Source Sans 3 lokal; Mitgliederbereich nutzt dieselben Tokens und die Wortmarke. - Kopfzeile, mobile Navigation, Untermenü (parent_id, ergänzend), Fußbereichsgruppen, vorbereiteter Warenkorbzugang (abgeschaltet). Öffentliche Seiten gleich für alle Besucher. - cms:revert-published als Wiederherstellungsweg vor einem Code-Rollback. Die Editor-Tests der ersten Iteration sind bewusst auf den neuen Formularzustand (sections statt blocks) umgestellt; ihre Prüfungen gelten unverändert für die Widgets. Der Vorschautest erwartet keine anmeldeabhängige Kopfzeile mehr (ADR-32). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
105 lines
3.3 KiB
PHP
105 lines
3.3 KiB
PHP
<?php
|
|
|
|
namespace App\Domain\Cms;
|
|
|
|
use Illuminate\Support\Collection;
|
|
|
|
/**
|
|
* Baut Kopf- und Fußnavigation aus dem CMS-Navigationsmodell. Keine fest codierten Menüpunkte.
|
|
*
|
|
* Die Ausgabe hängt nur von der Navigation und dem angefragten Pfad ab, nie vom Anmeldestatus,
|
|
* damit öffentliche Seiten für alle Besucher gleich ausgeliefert werden können (ADR-32).
|
|
*/
|
|
final class SiteNavigation
|
|
{
|
|
/**
|
|
* @param Collection<int, NavigationItem> $items sichtbare Einträge, sortiert
|
|
*/
|
|
public function __construct(private readonly Collection $items, private readonly string $currentPath) {}
|
|
|
|
/**
|
|
* @param Collection<int, NavigationItem> $items
|
|
*/
|
|
public static function forPath(Collection $items, string $path): self
|
|
{
|
|
return new self($items, '/'.trim($path, '/'));
|
|
}
|
|
|
|
/**
|
|
* Hauptnavigation mit einer Ebene Untermenü. Untereinträge eines ausgeblendeten Eintrags sind ebenfalls verborgen.
|
|
*
|
|
* @return list<array{id: int, label: string, href: ?string, current: bool, activeTrail: bool, children: list<array{id: int, label: string, href: string, current: bool}>}>
|
|
*/
|
|
public function header(): array
|
|
{
|
|
$topLevel = $this->items->where('placement', 'header')->whereNull('parent_id');
|
|
$entries = [];
|
|
|
|
foreach ($topLevel as $item) {
|
|
$children = [];
|
|
|
|
foreach ($this->items->where('parent_id', $item->id) as $child) {
|
|
$href = $child->href();
|
|
if ($href !== null) {
|
|
$children[] = [
|
|
'id' => $child->id,
|
|
'label' => $child->label,
|
|
'href' => $href,
|
|
'current' => $this->isCurrent($child),
|
|
];
|
|
}
|
|
}
|
|
|
|
$href = $item->href();
|
|
if ($href === null && $children === []) {
|
|
continue;
|
|
}
|
|
|
|
$current = $href !== null && $this->isCurrent($item);
|
|
|
|
$entries[] = [
|
|
'id' => $item->id,
|
|
'label' => $item->label,
|
|
'href' => $href,
|
|
'current' => $current,
|
|
'activeTrail' => $current || in_array(true, array_column($children, 'current'), true),
|
|
'children' => $children,
|
|
];
|
|
}
|
|
|
|
return $entries;
|
|
}
|
|
|
|
/**
|
|
* Spalten des Fußbereichs in fester Reihenfolge; Gruppen ohne Einträge entfallen.
|
|
*
|
|
* @return list<array{key: string, heading: string, links: list<array{label: string, href: string, current: bool}>}>
|
|
*/
|
|
public function footerGroups(): array
|
|
{
|
|
$groups = [];
|
|
|
|
foreach (NavigationItem::FOOTER_GROUPS as $placement => $heading) {
|
|
$links = [];
|
|
|
|
foreach ($this->items->where('placement', $placement) as $item) {
|
|
$href = $item->href();
|
|
if ($href !== null) {
|
|
$links[] = ['label' => $item->label, 'href' => $href, 'current' => $this->isCurrent($item)];
|
|
}
|
|
}
|
|
|
|
if ($links !== []) {
|
|
$groups[] = ['key' => $placement, 'heading' => $heading, 'links' => $links];
|
|
}
|
|
}
|
|
|
|
return $groups;
|
|
}
|
|
|
|
private function isCurrent(NavigationItem $item): bool
|
|
{
|
|
return $item->targetPath() === $this->currentPath;
|
|
}
|
|
}
|