blessing-skin-server/app/Listeners/SerializeGlobals.php
2020-05-06 11:45:01 +08:00

23 lines
544 B
PHP

<?php
namespace App\Listeners;
use stdClass;
class SerializeGlobals
{
public function handle($event)
{
$blessing = [
'version' => config('app.version'),
'locale' => config('app.locale'),
'base_url' => url('/'),
'site_name' => option_localized('site_name'),
'route' => request()->path(),
'i18n' => new stdClass(),
'extra' => [],
];
$event->addContent('<script>window.blessing = '.json_encode($blessing).';</script>');
}
}