- 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>
52 lines
1.5 KiB
PHP
52 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Themes;
|
|
|
|
use InvalidArgumentException;
|
|
|
|
/**
|
|
* The contents of a theme's theme.json.
|
|
*/
|
|
final readonly class ThemeManifest
|
|
{
|
|
/**
|
|
* @param array<string, array{label: string, default: string}> $tokens colour tokens, exposed as CSS variables --<key>
|
|
* @param array{css?: string, js?: string} $assets Vite entry points relative to the project root
|
|
*/
|
|
public function __construct(
|
|
public string $key,
|
|
public string $name,
|
|
public string $version,
|
|
public ?string $parent,
|
|
public string $description,
|
|
public array $tokens,
|
|
public array $assets,
|
|
public string $path,
|
|
) {}
|
|
|
|
public static function fromFile(string $file): self
|
|
{
|
|
$data = json_decode((string) file_get_contents($file), true, flags: JSON_THROW_ON_ERROR);
|
|
|
|
if (! is_array($data) || blank($data['key'] ?? null) || blank($data['name'] ?? null)) {
|
|
throw new InvalidArgumentException("Invalid theme manifest [{$file}]: key and name are required.");
|
|
}
|
|
|
|
return new self(
|
|
key: $data['key'],
|
|
name: $data['name'],
|
|
version: $data['version'] ?? '0.0.0',
|
|
parent: $data['parent'] ?? null,
|
|
description: $data['description'] ?? '',
|
|
tokens: $data['tokens'] ?? [],
|
|
assets: $data['assets'] ?? [],
|
|
path: dirname($file),
|
|
);
|
|
}
|
|
|
|
public function viewsPath(): string
|
|
{
|
|
return $this->path.DIRECTORY_SEPARATOR.'views';
|
|
}
|
|
}
|