Skip to content

Commit f1dc360

Browse files
foremtehanforemtehan
andauthored
[1.x] Resolve components when needed (2) (#360)
* resolve components when needed * reindent doc Co-authored-by: foremtehan <foremtehan@gmailcom>
1 parent 908c117 commit f1dc360

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

src/Listeners/GiveNewApplicationInstanceToAuthorizationGate.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ class GiveNewApplicationInstanceToAuthorizationGate
1414
*/
1515
public function handle($event): void
1616
{
17+
if (! $event->sandbox->resolved(Gate::class)) {
18+
return;
19+
}
20+
1721
$event->sandbox->make(Gate::class)->setContainer($event->sandbox);
1822
}
1923
}

src/Listeners/GiveNewApplicationInstanceToDatabaseSessionHandler.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ class GiveNewApplicationInstanceToDatabaseSessionHandler
1414
*/
1515
public function handle($event): void
1616
{
17+
if (! $event->sandbox->resolved('session')) {
18+
return;
19+
}
20+
1721
$handler = $event->sandbox->make('session')->driver()->getHandler();
1822

1923
if (! $handler instanceof DatabaseSessionHandler ||

src/Listeners/GiveNewApplicationInstanceToRouter.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ class GiveNewApplicationInstanceToRouter
1212
*/
1313
public function handle($event): void
1414
{
15+
if (! $event->sandbox->resolved('router')) {
16+
return;
17+
}
18+
1519
$event->sandbox->make('router')->setContainer($event->sandbox);
1620
}
1721
}

src/Listeners/GiveNewApplicationInstanceToViewFactory.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ class GiveNewApplicationInstanceToViewFactory
1212
*/
1313
public function handle($event): void
1414
{
15+
if (! $event->sandbox->resolved('view')) {
16+
return;
17+
}
18+
1519
with($event->sandbox->make('view'), function ($view) use ($event) {
1620
$view->setContainer($event->sandbox);
1721

0 commit comments

Comments
 (0)