-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[1.x] Give new app instance to cache manager (#667)
* Give new app instance to cache manager * ensure `setApplication` method exists
- Loading branch information
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/Listeners/GiveNewApplicationInstanceToCacheManager.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace Laravel\Octane\Listeners; | ||
|
||
class GiveNewApplicationInstanceToCacheManager | ||
{ | ||
/** | ||
* Handle the event. | ||
* | ||
* @param mixed $event | ||
* @return void | ||
*/ | ||
public function handle($event): void | ||
{ | ||
if (! $event->sandbox->resolved('cache')) { | ||
return; | ||
} | ||
|
||
with($event->sandbox->make('cache'), function ($manager) use ($event) { | ||
if (method_exists($manager, 'setApplication')) { | ||
$manager->setApplication($event->sandbox); | ||
} | ||
}); | ||
} | ||
} |