Files
fewo-stommer/app/Providers/AppServiceProvider.php
T

43 lines
1.4 KiB
PHP

<?php
namespace App\Providers;
use App\Support\StripImageMetadata;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\ServiceProvider;
use Spatie\MediaLibrary\MediaCollections\Events\MediaHasBeenAddedEvent;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
//
}
/**
* Bootstrap any application services.
*/
public function boot(): void
{
// Test environments: deliver every e-mail to one address only, so no guest gets test mails.
if (filled(config('fewo.mail_redirect_to'))) {
Mail::alwaysTo(config('fewo.mail_redirect_to'));
}
// Photos: remove metadata (GPS position, camera data) from uploaded originals, which stay downloadable.
Event::listen(MediaHasBeenAddedEvent::class, fn (MediaHasBeenAddedEvent $event) => StripImageMetadata::strip($event->media));
// On Strato the domain points at the deployment folder and .htaccess forwards to current/public;
// without a fixed root, some URLs (e.g. /sitemap.xml) would be generated with /current/public.
if (! $this->app->environment('local', 'testing')) {
URL::forceRootUrl(config('app.url'));
URL::forceScheme(parse_url((string) config('app.url'), PHP_URL_SCHEME) ?: 'https');
}
}
}