Konsolidierter Entwicklungsplan aus den zwei Analyse-Dokumenten plus
Umsetzung der Phase-0-Massnahmen (Korrektheit/Security, je mit Tests):
0.1 BasicAuth: timing-sicherer Vergleich (hash_equals, beide Felder ohne
Short-Circuit); Enabled-Check zur Laufzeit via config('auth.basic.*')
statt env() im Bootstrap-Closure (greift jetzt unter config:cache);
Config-Block + .env.example. Fund: auth.basic.* war nie als Config
definiert, Gate war faktisch unkonfigurierbar.
0.2 Legacy-Invoice-"latest"-Abfrage zentralisiert (LegacyInvoice::
scopeLatestFirst + User::latestLegacyInvoice); beide Consumer N+1-frei
umgestellt; unterschiedliches null-Verhalten bewusst erhalten.
0.3 Payment-Option-Eligibility vereinheitlicht (period-aware, strikt):
UserPaymentOption::scopeActiveNow/grandfatheredNow + User::
hasActivePaymentOption; hasActiveBooking/hasUnlimitedPressReleaseQuota
und ApiAccessEligibilityService darauf umgestellt; $hasGrandfathered-
Mislabel behoben.
0.4 Theme->Portal-Vokabular: totes, projektfremdes ThemeMiddleware
geloescht; Mapping in Portal::fromTheme() zentralisiert; fremden
b2in-Default im ThemeServiceProvider auf Portal-Default korrigiert.
0.5 InvoiceNumberGenerator: Erst-Insert race-sicher via insertOrIgnore
(Unique-Index auf circle existiert bereits). CreditWalletService war
bereits abgesichert (Unique-Index + createOrFirst).
Tests: 4 neue Dateien, 5 bestehende auf gueltiges grandfathered_until
angepasst. Volle Suite gruen (793 passed, 1 skipped).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
53 lines
1.5 KiB
PHP
53 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Enums;
|
|
|
|
enum Portal: string
|
|
{
|
|
case Presseecho = 'presseecho';
|
|
case Businessportal24 = 'businessportal24';
|
|
case Both = 'both';
|
|
|
|
/**
|
|
* Mappt ein Domain-Theme (aus config/domains.php, gesetzt vom
|
|
* ThemeServiceProvider) auf das zugehörige Portal. Admin-/Hub-Themes
|
|
* (portal, pressekonto, main, …) liefern null → kein Portal-Filter.
|
|
* Single Source of Truth für die Theme→Portal-Auflösung.
|
|
*/
|
|
public static function fromTheme(?string $theme): ?self
|
|
{
|
|
return match ($theme) {
|
|
'presseecho' => self::Presseecho,
|
|
'businessportal24' => self::Businessportal24,
|
|
default => null,
|
|
};
|
|
}
|
|
|
|
public function label(): string
|
|
{
|
|
return match ($this) {
|
|
self::Presseecho => 'Presseecho',
|
|
self::Businessportal24 => 'Businessportal24',
|
|
self::Both => 'Beide Portale',
|
|
};
|
|
}
|
|
|
|
public function abbreviation(): string
|
|
{
|
|
return match ($this) {
|
|
self::Presseecho => 'PE',
|
|
self::Businessportal24 => 'B24',
|
|
self::Both => 'PE+B24',
|
|
};
|
|
}
|
|
|
|
public static function stripTrailingAbbreviation(string $value): string
|
|
{
|
|
$abbreviations = implode('|', array_map(
|
|
fn (self $portal): string => preg_quote($portal->abbreviation(), '/'),
|
|
self::cases(),
|
|
));
|
|
|
|
return trim((string) preg_replace('/\s*\(('.$abbreviations.')\)\s*$/u', '', $value));
|
|
}
|
|
}
|