update 20.10.2025

This commit is contained in:
Kevin Adametz 2025-10-20 17:42:08 +02:00
parent 8c11130b5d
commit a939cd51ef
616 changed files with 84821 additions and 4121 deletions

View file

@ -2,7 +2,8 @@
namespace App\Providers;
use App\Domain\DomainContext;
// use App\Domain\DomainContext; // HOTFIX: Temporär deaktiviert
use App\Domain\EarlyDomainParser;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Http\Request;
@ -32,7 +33,7 @@ class RouteServiceProvider extends ServiceProvider
*/
public function boot()
{
// $this->configureRateLimiting();
$this->configureRateLimiting();
$this->routes(function () {
// API-Routen werden global geladen
@ -44,65 +45,64 @@ class RouteServiceProvider extends ServiceProvider
// Web-Routen werden domain-bewusst geladen
Route::middleware('web')
->namespace($this->namespace)
->group(function() {
->group(function () {
$this->loadDomainAwareRoutes();
});
});
}
/**
* Lädt Routen basierend auf dem aktuellen Domain-Kontext.
* Lädt Routen basierend auf der domains.php Konfiguration.
* Vereinfachter Ansatz ohne DomainContext-Abhängigkeit
*/
protected function loadDomainAwareRoutes(): void
{
/** @var DomainContext $context */
$context = app(DomainContext::class);
$request = $this->app->make('request');
$this->loadSharedRoutes();
\Log::info('loadDomainAwareRoutes', ['context' => $context]);
match ($context->type) {
'main' => $this->loadDomainRoutes('main', 'main.php'),
'main-shop' => [
$this->loadDomainRoutes('shop', 'shop.php'),
$this->loadDomainRoutes('portal', 'portal.php'),
],
'user-shop' => [
$this->loadDomainRoutes('user-shop', 'user-shop.php'),
$this->loadDomainRoutes('portal', 'portal.php'),
],
'crm' => $this->loadDomainRoutes('crm', 'crm.php'),
'portal' => $this->loadDomainRoutes('portal', 'portal.php'),
'checkout' => $this->loadDomainRoutes('checkout', 'checkout.php'),
default => $this->loadAllDomainRoutesForCaching(),
// Lade alle Domain-spezifischen Routen
// Die Domain-Logik wird von SubdomainResolver Middleware behandelt
$domainType = EarlyDomainParser::getCurrentDomainType($request->getHost());
$routesToLoad = match ($domainType) {
'main' => ['main'],
'main-shop' => ['shop', 'portal'],
'user-shop' => ['user-shop', 'portal'],
'crm' => ['crm'],
'portal' => ['portal'],
'checkout' => ['checkout'],
'unknown' => ['main'], // Fallback für unbekannte Domains
default => ['main'],
};
foreach ($routesToLoad as $routeType) {
$this->loadDomainRoutes($routeType, $routeType . '.php');
}
if (config('app.debug')) {
\Log::channel('domain')->info('Domain-aware routes loaded', [
'domain_type' => $domainType,
'routes_loaded' => $routesToLoad,
'host' => EarlyDomainParser::parseDomain()['host'],
]);
}
}
/**
* Lädt eine spezifische Routendatei für eine Domain.
*/
protected function loadDomainRoutes(string $domainType, string $fileName): void
{
$domain = config("domains.domains.{$domainType}.host");
Route::domain($domain)
->group(base_path('routes/domains/' . $fileName));
}
$routePath = base_path('routes/domains/' . $fileName);
/**
* Lädt alle domainspezifischen Routen.
* Wird als Fallback für das Route-Caching benötigt.
*/
protected function loadAllDomainRoutesForCaching(): void
{
if (app()->routesAreCached()) {
return;
if (file_exists($routePath)) {
Route::group([], $routePath);
} else {
if (config('app.debug')) {
\Log::channel('domain')->warning('Domain route file not found', [
'domain_type' => $domainType,
'file_path' => $routePath,
]);
}
}
$this->loadDomainRoutes('main', 'main.php');
$this->loadDomainRoutes('shop', 'shop.php');
$this->loadDomainRoutes('crm', 'crm.php');
$this->loadDomainRoutes('portal', 'portal.php');
$this->loadDomainRoutes('checkout', 'checkout.php');
$this->loadDomainRoutes('user-shop', 'user-shop.php');
}
/**