From 9dd3413700c63e977beab145e909effe908ce4e9 Mon Sep 17 00:00:00 2001 From: foremtehan Date: Fri, 6 Aug 2021 18:23:07 +0430 Subject: [PATCH 1/2] resolve components when needed --- .../GiveNewApplicationInstanceToAuthorizationGate.php | 6 +++++- .../GiveNewApplicationInstanceToDatabaseSessionHandler.php | 4 ++++ src/Listeners/GiveNewApplicationInstanceToRouter.php | 4 ++++ src/Listeners/GiveNewApplicationInstanceToViewFactory.php | 4 ++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Listeners/GiveNewApplicationInstanceToAuthorizationGate.php b/src/Listeners/GiveNewApplicationInstanceToAuthorizationGate.php index f959917d0..7e8ad89a0 100644 --- a/src/Listeners/GiveNewApplicationInstanceToAuthorizationGate.php +++ b/src/Listeners/GiveNewApplicationInstanceToAuthorizationGate.php @@ -9,11 +9,15 @@ class GiveNewApplicationInstanceToAuthorizationGate /** * Handle the event. * - * @param mixed $event + * @param mixed $event * @return void */ public function handle($event): void { + if (! $event->sandbox->resolved(Gate::class)) { + return; + } + $event->sandbox->make(Gate::class)->setContainer($event->sandbox); } } diff --git a/src/Listeners/GiveNewApplicationInstanceToDatabaseSessionHandler.php b/src/Listeners/GiveNewApplicationInstanceToDatabaseSessionHandler.php index 808279620..a6bbabaa6 100644 --- a/src/Listeners/GiveNewApplicationInstanceToDatabaseSessionHandler.php +++ b/src/Listeners/GiveNewApplicationInstanceToDatabaseSessionHandler.php @@ -14,6 +14,10 @@ class GiveNewApplicationInstanceToDatabaseSessionHandler */ public function handle($event): void { + if (! $event->sandbox->resolved('session')) { + return; + } + $handler = $event->sandbox->make('session')->driver()->getHandler(); if (! $handler instanceof DatabaseSessionHandler || diff --git a/src/Listeners/GiveNewApplicationInstanceToRouter.php b/src/Listeners/GiveNewApplicationInstanceToRouter.php index ae3e52ccc..393ae94b8 100644 --- a/src/Listeners/GiveNewApplicationInstanceToRouter.php +++ b/src/Listeners/GiveNewApplicationInstanceToRouter.php @@ -12,6 +12,10 @@ class GiveNewApplicationInstanceToRouter */ public function handle($event): void { + if (! $event->sandbox->resolved('router')) { + return; + } + $event->sandbox->make('router')->setContainer($event->sandbox); } } diff --git a/src/Listeners/GiveNewApplicationInstanceToViewFactory.php b/src/Listeners/GiveNewApplicationInstanceToViewFactory.php index 7a1551de3..3c3642816 100644 --- a/src/Listeners/GiveNewApplicationInstanceToViewFactory.php +++ b/src/Listeners/GiveNewApplicationInstanceToViewFactory.php @@ -12,6 +12,10 @@ class GiveNewApplicationInstanceToViewFactory */ public function handle($event): void { + if (! $event->sandbox->resolved('view')) { + return; + } + with($event->sandbox->make('view'), function ($view) use ($event) { $view->setContainer($event->sandbox); From 9be7c679efd5c3bdce14a23b994104852b73959d Mon Sep 17 00:00:00 2001 From: foremtehan Date: Fri, 6 Aug 2021 18:33:59 +0430 Subject: [PATCH 2/2] reindent doc --- src/Listeners/GiveNewApplicationInstanceToAuthorizationGate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Listeners/GiveNewApplicationInstanceToAuthorizationGate.php b/src/Listeners/GiveNewApplicationInstanceToAuthorizationGate.php index 7e8ad89a0..84f8e98f8 100644 --- a/src/Listeners/GiveNewApplicationInstanceToAuthorizationGate.php +++ b/src/Listeners/GiveNewApplicationInstanceToAuthorizationGate.php @@ -9,7 +9,7 @@ class GiveNewApplicationInstanceToAuthorizationGate /** * Handle the event. * - * @param mixed $event + * @param mixed $event * @return void */ public function handle($event): void