- Sites (Domain, Theme, Farben; mehrfähig für weitere Vermieter), Seiten aus Bausteinen mit Menüs, Erscheinungsbilder mit jährlichem Zeitplan, Priorität und signierter Vorschau - Theme-Kern (app/Themes): Manifest, Registry, Vererbung (Child-Themes), Token-Farben als CSS-Variablen, Bausteinkatalog als Registry (config/themes.php) - 15 Bausteine: Titelbereich mit Suche, Eckdaten, Text mit Bildern, Galerie, Ausstattung, Lage, Preise, Angebote, Kalender & Anfrage, Bewertungen, Gastgeber, FAQ, Abschluss, Kontakt, Fließtext - Theme Ostsee-Licht: Layout, Kopf/Fuß, Banner, mobile Buchungsleiste, Lightbox, selbst gehostete Schriften, Reduced Motion - Seiten Start, Wohnung, Kühlungsborn, Preise & Buchung, Kontakt, Impressum, Datenschutz; Sitemap, robots.txt, JSON-LD - Admin: Seiten-Baukasten, Erscheinungsbilder, Websites - Dokumentation docs/THEMES.md inkl. Übergabe für die Design-Sitzung Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
72 lines
2.0 KiB
PHP
72 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Themes;
|
|
|
|
use App\Themes\Sections\Section;
|
|
use Filament\Forms\Components\Builder\Block;
|
|
use Illuminate\Contracts\View\View;
|
|
use Illuminate\Support\Facades\View as ViewFactory;
|
|
|
|
/**
|
|
* The section catalogue from config/themes.php: builder blocks for the admin and rendering for the website.
|
|
*/
|
|
class SectionRegistry
|
|
{
|
|
/**
|
|
* @return array<string, class-string<Section>>
|
|
*/
|
|
public function all(): array
|
|
{
|
|
return collect(config('themes.sections'))
|
|
->mapWithKeys(fn (string $class): array => [$class::key() => $class])
|
|
->all();
|
|
}
|
|
|
|
public function get(string $key): ?Section
|
|
{
|
|
$class = $this->all()[$key] ?? null;
|
|
|
|
return $class ? app($class) : null;
|
|
}
|
|
|
|
/**
|
|
* @return list<Block>
|
|
*/
|
|
public function blocks(): array
|
|
{
|
|
return array_values(array_map(
|
|
fn (string $class): Block => Block::make($class::key())
|
|
->label($class::label())
|
|
->icon($class::icon())
|
|
->schema($class::schema()),
|
|
$this->all(),
|
|
));
|
|
}
|
|
|
|
/**
|
|
* Renders the stored sections of a page; unknown or failing types are skipped (and reported),
|
|
* so a page never breaks because of one section.
|
|
*
|
|
* @param list<array{type: string, data?: array<string, mixed>}>|null $sections
|
|
* @return list<View>
|
|
*/
|
|
public function render(Theme $theme, ?array $sections): array
|
|
{
|
|
$views = [];
|
|
foreach ($sections ?? [] as $index => $stored) {
|
|
$section = $this->get($stored['type'] ?? '');
|
|
if ($section === null || ! ViewFactory::exists($section->view())) {
|
|
continue;
|
|
}
|
|
|
|
$views[] = ViewFactory::make($section->view(), [
|
|
...$section->data($theme, $stored['data'] ?? []),
|
|
'theme' => $theme,
|
|
'sectionId' => $section::key().'-'.$index,
|
|
]);
|
|
}
|
|
|
|
return $views;
|
|
}
|
|
}
|