Skip to content

Commit

Permalink
[1.x] Resolve components when needed (2) (#360)
Browse files Browse the repository at this point in the history
* resolve components when needed

* reindent doc

Co-authored-by: foremtehan <foremtehan@gmailcom>
  • Loading branch information
foremtehan and foremtehan committed Aug 7, 2021
1 parent 908c117 commit f1dc360
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ class GiveNewApplicationInstanceToAuthorizationGate
*/
public function handle($event): void
{
if (! $event->sandbox->resolved(Gate::class)) {
return;
}

$event->sandbox->make(Gate::class)->setContainer($event->sandbox);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand Down
4 changes: 4 additions & 0 deletions src/Listeners/GiveNewApplicationInstanceToRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ class GiveNewApplicationInstanceToRouter
*/
public function handle($event): void
{
if (! $event->sandbox->resolved('router')) {
return;
}

$event->sandbox->make('router')->setContainer($event->sandbox);
}
}
4 changes: 4 additions & 0 deletions src/Listeners/GiveNewApplicationInstanceToViewFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit f1dc360

Please sign in to comment.