mivita/app/Providers/AppServiceProvider.php
Kevin Adametz 4274bff9e2 Composer-Sicherheitsupdates, dompdf 3, email-Regel ohne Zeilenumbrueche
- Patch-/Minor-Updates (guzzle, commonmark, flysystem, excel,
  phpspreadsheet, phpseclib, laravel/framework 11.x)
- barryvdh/laravel-dompdf 3.1 (dompdf 3.1.6), Test fuer den PDF-Weg
  inkl. eingebettetem PHP und Briefpapier
- Rueckport des Laravel-12.60-Fixes gegen CRLF in der email-Regel
- Protokoll: Ergebnis composer audit, offene Punkte Laravel 12 und
  PDF-Seitenzahlen

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 12:50:31 +00:00

101 lines
3.9 KiB
PHP

<?php
namespace App\Providers;
use App\Services\Backoffice\BackofficeDashboardService;
use App\Services\Payment\Payone\PayonePaymentService;
use App\Services\Payment\Stripe\StripeClientWrapper;
use App\Services\Util;
use App\Support\OperationalAlert;
use App\Support\Validation\Validator as SafeEmailValidator;
use Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider;
use Illuminate\Foundation\Console\AboutCommand;
use Illuminate\Pagination\Paginator;
use Illuminate\Queue\Events\JobFailed;
use Illuminate\Support\Facades\Queue;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Schema::defaultStringLength(191);
Validator::resolver(fn ($translator, $data, $rules, $messages, $attributes) => new SafeEmailValidator($translator, $data, $rules, $messages, $attributes));
Paginator::defaultView('pagination::bootstrap-4');
Paginator::defaultSimpleView('pagination::simple-bootstrap-4');
if ($this->app->environment('production')) {
URL::forceScheme('https');
}
Queue::failing(function (JobFailed $event): void {
OperationalAlert::send('Queue-Job fehlgeschlagen: '.$event->job->resolveName(), [
'connection' => $event->connectionName,
'queue' => $event->job->getQueue(),
'exception' => $event->exception->getMessage(),
]);
});
AboutCommand::add('mivita', fn (): array => [
'Version' => config('app.version') ?? 'unbekannt',
]);
// Domain-bewusster View Composer für user_shop
// HOTFIX: DomainContext temporär deaktiviert
// TODO: Nach Claude v2 Implementation wieder aktivieren
\View::composer('*', function ($view) {
try {
// $context = app(\App\Domain\DomainContext::class);
// if ($context->type === 'main') {
// $view->with('user_shop', null);
// } else {
// $userShop = $context->userShop ?? \App\Services\Util::getUserShop();
// $view->with('user_shop', $userShop);
// }
// Temporär: Verwende immer das normale Verhalten
$view->with('user_shop', Util::getUserShop());
} catch (\Exception $e) {
// Fallback bei Fehlern
$view->with('user_shop', Util::getUserShop());
}
});
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
// PAYONE payment service: built from merchant defaults, real Guzzle client at runtime.
// The per-request `mode` is always passed explicitly to the service methods, so the
// shared singleton needs only the base defaults from config.
$this->app->singleton(PayonePaymentService::class, function () {
return new PayonePaymentService(config('payone.defaults'));
});
// Stripe: lazy Client-Hülle; Hard-Fail erst bei Nutzung ohne STRIPE_SECRET
// (Dark-Launch-fähig, siehe config/stripe.php + dev/2026-07-08-stripe/).
$this->app->singleton(StripeClientWrapper::class, function () {
return new StripeClientWrapper(config('stripe.secret'));
});
// Dashboard-Services teilen die Baum-Traversierung (lineBuckets-Memo):
// als Singleton läuft die Downline-BFS pro Request/Prozess nur einmal je Root.
$this->app->singleton(BackofficeDashboardService::class);
if ($this->app->environment() !== 'production' && class_exists(IdeHelperServiceProvider::class)) {
$this->app->register(IdeHelperServiceProvider::class);
}
}
}