From 79717cae5cfd16ac2d002ee4b4f9d36471301eea Mon Sep 17 00:00:00 2001 From: Younes ENNAJI Date: Sun, 22 Sep 2024 15:26:49 +0100 Subject: [PATCH] refactor: FlasherServiceProvider Update HttpKernel import and reorder methods - Changed HttpKernel import from Illuminate\Foundation\Http\Kernel to Illuminate\Contracts\Http\Kernel to use the contract interface instead of the concrete implementation. - Moved registerCspHandler() and registerAssetManager() methods after registerSessionMiddleware() to improve code organization and ensure correct initialization order. --- src/Laravel/FlasherServiceProvider.php | 36 +++++++++++++------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Laravel/FlasherServiceProvider.php b/src/Laravel/FlasherServiceProvider.php index 95243e3d..e55dc732 100644 --- a/src/Laravel/FlasherServiceProvider.php +++ b/src/Laravel/FlasherServiceProvider.php @@ -35,9 +35,9 @@ use Flasher\Prime\Storage\Storage; use Flasher\Prime\Storage\StorageManager; use Illuminate\Container\Container; use Illuminate\Contracts\Events\Dispatcher; +use Illuminate\Contracts\Http\Kernel as HttpKernel; use Illuminate\Foundation\Application; use Illuminate\Foundation\Console\AboutCommand; -use Illuminate\Foundation\Http\Kernel as HttpKernel; use Illuminate\View\Compilers\BladeCompiler; use Laravel\Octane\Events\RequestReceived; use Livewire\LivewireManager; @@ -236,23 +236,6 @@ final class FlasherServiceProvider extends PluginServiceProvider $this->pushMiddlewareToGroup(FlasherMiddleware::class); } - private function registerCspHandler(): void - { - $this->app->singleton('flasher.csp_handler', static function () { - return new ContentSecurityPolicyHandler(new NonceGenerator()); - }); - } - - private function registerAssetManager(): void - { - $this->app->singleton('flasher.asset_manager', static function () { - $publicDir = public_path('/'); - $manifestPath = public_path('vendor'.\DIRECTORY_SEPARATOR.'flasher'.\DIRECTORY_SEPARATOR.'manifest.json'); - - return new AssetManager($publicDir, $manifestPath); - }); - } - private function registerSessionMiddleware(): void { if (!$this->getConfig('flash_bag')) { @@ -278,6 +261,23 @@ final class FlasherServiceProvider extends PluginServiceProvider }); } + private function registerCspHandler(): void + { + $this->app->singleton('flasher.csp_handler', static function () { + return new ContentSecurityPolicyHandler(new NonceGenerator()); + }); + } + + private function registerAssetManager(): void + { + $this->app->singleton('flasher.asset_manager', static function () { + $publicDir = public_path('/'); + $manifestPath = public_path('vendor'.\DIRECTORY_SEPARATOR.'flasher'.\DIRECTORY_SEPARATOR.'manifest.json'); + + return new AssetManager($publicDir, $manifestPath); + }); + } + private function registerBladeDirectives(BladeCompiler $blade): void { $blade->directive('flasher_render', function (string $expression = '') {