diff --git a/app/Listeners/SerializeGlobals.php b/app/Listeners/SerializeGlobals.php new file mode 100644 index 00000000..28c44837 --- /dev/null +++ b/app/Listeners/SerializeGlobals.php @@ -0,0 +1,20 @@ + config('app.version'), + 'locale' => config('app.locale'), + 'fallback_locale' => config('app.fallback_locale'), + 'base_url' => url('/'), + 'site_name' => option_localized('site_name'), + 'route' => request()->path(), + 'extra' => [], + ]; + $event->addContent(''); + } +} diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index da5ab7b6..b1978f11 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,10 +2,8 @@ namespace App\Providers; -use App\Events; use App\Exceptions\PrettyPageException; use App\Services; -use Event; use Illuminate\Http\Request; use Illuminate\Support\Facades\Redis; use Illuminate\Support\ServiceProvider; @@ -32,27 +30,13 @@ class AppServiceProvider extends ServiceProvider /** * Bootstrap any application services. * - * @return void + * @codeCoverageIgnore */ public function boot(Request $request) { // Control the URL generated by url() function $this->configureUrlGenerator($request); - Event::listen(Events\RenderingHeader::class, function ($event) { - $blessing = [ - 'version' => config('app.version'), - 'locale' => config('app.locale'), - 'fallback_locale' => config('app.fallback_locale'), - 'base_url' => url('/'), - 'site_name' => option_localized('site_name'), - 'route' => request()->path(), - 'extra' => [], - ]; - $event->addContent(''); - }); - - // @codeCoverageIgnoreStart try { $this->app->make('cipher'); } catch (\Illuminate\Contracts\Container\BindingResolutionException $e) { @@ -69,7 +53,6 @@ class AppServiceProvider extends ServiceProvider } } catch (\Exception $e) { } - // @codeCoverageIgnoreEnd } /** diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index 02c5f5be..2984d3cf 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -32,6 +32,9 @@ class EventServiceProvider extends ServiceProvider 'App\Events\PluginBootFailed' => [ 'App\Listeners\NotifyFailedPlugin', ], + 'App\Events\RenderingHeader' => [ + 'App\Listeners\SerializeGlobals', + ], ]; /**