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.
This commit is contained in:
Younes ENNAJI
2024-09-22 15:26:49 +01:00
parent 6fe3407fae
commit 79717cae5c
+18 -18
View File
@@ -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 = '') {