Skip to content

Commit 61d7c81

Browse files
authored
[1.x] Give new app instance to cache manager (#667)
* Give new app instance to cache manager * ensure `setApplication` method exists
1 parent da35868 commit 61d7c81

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/Concerns/ProvidesDefaultConfigurationOptions.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public static function prepareApplicationForNextOperation(): array
4141
\Laravel\Octane\Listeners\GiveNewApplicationInstanceToMailManager::class,
4242
\Laravel\Octane\Listeners\GiveNewApplicationInstanceToNotificationChannelManager::class,
4343
\Laravel\Octane\Listeners\GiveNewApplicationInstanceToPipelineHub::class,
44+
\Laravel\Octane\Listeners\GiveNewApplicationInstanceToCacheManager::class,
4445
\Laravel\Octane\Listeners\GiveNewApplicationInstanceToQueueManager::class,
4546
\Laravel\Octane\Listeners\GiveNewApplicationInstanceToRouter::class,
4647
\Laravel\Octane\Listeners\GiveNewApplicationInstanceToValidationFactory::class,
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace Laravel\Octane\Listeners;
4+
5+
class GiveNewApplicationInstanceToCacheManager
6+
{
7+
/**
8+
* Handle the event.
9+
*
10+
* @param mixed $event
11+
* @return void
12+
*/
13+
public function handle($event): void
14+
{
15+
if (! $event->sandbox->resolved('cache')) {
16+
return;
17+
}
18+
19+
with($event->sandbox->make('cache'), function ($manager) use ($event) {
20+
if (method_exists($manager, 'setApplication')) {
21+
$manager->setApplication($event->sandbox);
22+
}
23+
});
24+
}
25+
}

0 commit comments

Comments
 (0)