Skip to content

Commit 54e6677

Browse files
authored
give new application instance to database session handler (#302)
1 parent b39021d commit 54e6677

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/Concerns/ProvidesDefaultConfigurationOptions.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public static function prepareApplicationForNextOperation(): array
3535
\Laravel\Octane\Listeners\GiveNewApplicationInstanceToAuthorizationGate::class,
3636
\Laravel\Octane\Listeners\GiveNewApplicationInstanceToBroadcastManager::class,
3737
\Laravel\Octane\Listeners\GiveNewApplicationInstanceToDatabaseManager::class,
38+
\Laravel\Octane\Listeners\GiveNewApplicationInstanceToDatabaseSessionHandler::class,
3839
\Laravel\Octane\Listeners\GiveNewApplicationInstanceToHttpKernel::class,
3940
\Laravel\Octane\Listeners\GiveNewApplicationInstanceToMailManager::class,
4041
\Laravel\Octane\Listeners\GiveNewApplicationInstanceToNotificationChannelManager::class,
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace Laravel\Octane\Listeners;
4+
5+
use Illuminate\Session\DatabaseSessionHandler;
6+
7+
class GiveNewApplicationInstanceToDatabaseSessionHandler
8+
{
9+
/**
10+
* Handle the event.
11+
*
12+
* @param mixed $event
13+
* @return void
14+
*/
15+
public function handle($event): void
16+
{
17+
$handler = $event->sandbox->make('session')->driver()->getHandler();
18+
19+
if (! $handler instanceof DatabaseSessionHandler ||
20+
! method_exists($handler, 'setContainer')) {
21+
return;
22+
}
23+
24+
$handler->setContainer($event->sandbox);
25+
}
26+
}

0 commit comments

Comments
 (0)