Blendet den B2IN-Text-Verlauf ohne Footer aus, zeigt 9:16-Format-Badges in der Mediathek, normalisiert Modul-Booleans und korrigiert Flux-Switches im Dark Mode. Co-authored-by: Cursor <cursoragent@cursor.com>
106 lines
3.1 KiB
PHP
106 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace App\Support;
|
|
|
|
use App\Enums\DisplayVersionType;
|
|
|
|
class DisplayModuleSettings
|
|
{
|
|
/** @var list<string> */
|
|
private const B2IN_BOOLEAN_KEYS = [
|
|
'show_logo',
|
|
'show_claim',
|
|
'show_footer',
|
|
'display_active',
|
|
];
|
|
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public static function defaults(DisplayVersionType|string $type): array
|
|
{
|
|
$typeValue = $type instanceof DisplayVersionType ? $type->value : $type;
|
|
|
|
return match ($typeValue) {
|
|
DisplayVersionType::VideoDisplay->value => [
|
|
'qr_label' => 'Website',
|
|
],
|
|
DisplayVersionType::B2in->value => [
|
|
'theme' => 'dark',
|
|
'header_logo_url' => '/_cabinet/assets/b2in-logo-positive.svg',
|
|
'header_claim' => 'Connecting Design & Property',
|
|
'logo_position' => 'top-left',
|
|
'claim_position' => 'top-right',
|
|
'show_logo' => true,
|
|
'show_claim' => true,
|
|
'show_footer' => true,
|
|
'footer_url' => 'B2in.eu',
|
|
'footer_name' => '',
|
|
'footer_prefix' => 'by',
|
|
'qr_url' => '',
|
|
'transition' => [
|
|
'type' => 'crossfade',
|
|
'duration_ms' => 800,
|
|
],
|
|
'default_image_duration' => 10,
|
|
'rotation_weights' => ['immobilien' => 70, 'moebel' => 30],
|
|
'display_active' => true,
|
|
],
|
|
DisplayVersionType::Offers->value => [
|
|
'loop' => true,
|
|
'transition' => [
|
|
'type' => 'fade',
|
|
'duration' => 600,
|
|
],
|
|
],
|
|
default => [],
|
|
};
|
|
}
|
|
|
|
/**
|
|
* @param array<string, mixed>|null $settings
|
|
* @return array<string, mixed>
|
|
*/
|
|
public static function merge(DisplayVersionType|string $type, ?array $settings): array
|
|
{
|
|
$merged = array_replace_recursive(self::defaults($type), $settings ?? []);
|
|
|
|
$typeValue = $type instanceof DisplayVersionType ? $type->value : $type;
|
|
|
|
if ($typeValue === DisplayVersionType::B2in->value) {
|
|
return self::normalizeB2inBooleans($merged);
|
|
}
|
|
|
|
if ($typeValue === DisplayVersionType::Offers->value && array_key_exists('loop', $merged)) {
|
|
$merged['loop'] = self::toBool($merged['loop']);
|
|
}
|
|
|
|
return $merged;
|
|
}
|
|
|
|
/**
|
|
* @param array<string, mixed> $settings
|
|
* @return array<string, mixed>
|
|
*/
|
|
private static function normalizeB2inBooleans(array $settings): array
|
|
{
|
|
foreach (self::B2IN_BOOLEAN_KEYS as $key) {
|
|
if (array_key_exists($key, $settings)) {
|
|
$settings[$key] = self::toBool($settings[$key]);
|
|
}
|
|
}
|
|
|
|
return $settings;
|
|
}
|
|
|
|
private static function toBool(mixed $value): bool
|
|
{
|
|
if (is_bool($value)) {
|
|
return $value;
|
|
}
|
|
|
|
$filtered = filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
|
|
|
|
return $filtered ?? (bool) $value;
|
|
}
|
|
}
|