Skip to content

Commit

Permalink
[1.x] Give new app instance to cache manager (#667)
Browse files Browse the repository at this point in the history
* Give new app instance to cache manager

* ensure `setApplication` method exists
  • Loading branch information
smortexa authored Mar 27, 2023
1 parent da35868 commit 61d7c81
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Concerns/ProvidesDefaultConfigurationOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public static function prepareApplicationForNextOperation(): array
\Laravel\Octane\Listeners\GiveNewApplicationInstanceToMailManager::class,
\Laravel\Octane\Listeners\GiveNewApplicationInstanceToNotificationChannelManager::class,
\Laravel\Octane\Listeners\GiveNewApplicationInstanceToPipelineHub::class,
\Laravel\Octane\Listeners\GiveNewApplicationInstanceToCacheManager::class,
\Laravel\Octane\Listeners\GiveNewApplicationInstanceToQueueManager::class,
\Laravel\Octane\Listeners\GiveNewApplicationInstanceToRouter::class,
\Laravel\Octane\Listeners\GiveNewApplicationInstanceToValidationFactory::class,
Expand Down
25 changes: 25 additions & 0 deletions src/Listeners/GiveNewApplicationInstanceToCacheManager.php
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);
}
});
}
}

0 comments on commit 61d7c81

Please sign in to comment.