Skip to content

Commit

Permalink
Give new app instance to database manager (#225)
Browse files Browse the repository at this point in the history
* give new app instance to database manager

* Update ProvidesDefaultConfigurationOptions.php

* Update GiveNewApplicationInstanceToDatabaseManager.php

* Apply fixes from StyleCI (#226)

Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
themsaid and taylorotwell committed Apr 21, 2021
1 parent 83f7687 commit 553ea01
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
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);
});
}
}

0 comments on commit 553ea01

Please sign in to comment.