Refactor
This commit is contained in:
parent
facd92356c
commit
ad1201b226
20
app/Listeners/SerializeGlobals.php
Normal file
20
app/Listeners/SerializeGlobals.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Listeners;
|
||||
|
||||
class SerializeGlobals
|
||||
{
|
||||
public function handle($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('<script>const blessing = '.json_encode($blessing).';</script>');
|
||||
}
|
||||
}
|
@ -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('<script>var blessing = '.json_encode($blessing).';</script>');
|
||||
});
|
||||
|
||||
// @codeCoverageIgnoreStart
|
||||
try {
|
||||
$this->app->make('cipher');
|
||||
} catch (\Illuminate\Contracts\Container\BindingResolutionException $e) {
|
||||
@ -69,7 +53,6 @@ class AppServiceProvider extends ServiceProvider
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -32,6 +32,9 @@ class EventServiceProvider extends ServiceProvider
|
||||
'App\Events\PluginBootFailed' => [
|
||||
'App\Listeners\NotifyFailedPlugin',
|
||||
],
|
||||
'App\Events\RenderingHeader' => [
|
||||
'App\Listeners\SerializeGlobals',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user