Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give new app instance to database manager #225

Merged
merged 4 commits into from Apr 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Concerns/ProvidesDefaultConfigurationOptions.php
Expand Up @@ -34,6 +34,7 @@ public static function prepareApplicationForNextOperation(): array
\Laravel\Octane\Listeners\CreateConfigurationSandbox::class,
\Laravel\Octane\Listeners\GiveNewApplicationInstanceToAuthorizationGate::class,
\Laravel\Octane\Listeners\GiveNewApplicationInstanceToBroadcastManager::class,
\Laravel\Octane\Listeners\GiveNewApplicationInstanceToDatabaseManager::class,
\Laravel\Octane\Listeners\GiveNewApplicationInstanceToHttpKernel::class,
\Laravel\Octane\Listeners\GiveNewApplicationInstanceToMailManager::class,
\Laravel\Octane\Listeners\GiveNewApplicationInstanceToNotificationChannelManager::class,
Expand Down
24 changes: 24 additions & 0 deletions src/Listeners/GiveNewApplicationInstanceToDatabaseManager.php
@@ -0,0 +1,24 @@
<?php

namespace Laravel\Octane\Listeners;

class GiveNewApplicationInstanceToDatabaseManager
{
/**
* Handle the event.
*
* @param mixed $event
* @return void
*/
public function handle($event): void
{
if (! $event->sandbox->resolved('db') ||
! method_exists($event->sandbox->make('db'), 'setApplication')) {
return;
}

with($event->sandbox->make('db'), function ($manager) use ($event) {
$manager->setApplication($event->sandbox);
});
}
}