Skip to content

Commit

Permalink
firstly register op_service_providers and then boot them
Browse files Browse the repository at this point in the history
  • Loading branch information
tornike committed Jul 31, 2024
1 parent 3e72350 commit 6b7c52f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/ApplicationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ protected function getBootstrappers(Application $app): array

$bootstrappers = $method->invoke($kernel);

// Replace RegisterProviders with OctaneRegisterProviders
$replaceIndex = array_search(RegisterProviders::class, $bootstrappers, true);
$bootstrappers = array_replace($bootstrappers, [$replaceIndex => OctaneRegisterProviders::class]);

Expand Down
9 changes: 8 additions & 1 deletion src/Listeners/RegisterOperationServiceProviders.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,15 @@ class RegisterOperationServiceProviders
*/
public function handle($event): void
{
$resolved_providers = [];

foreach ($event->sandbox->make('config')->get('octane.op_service_providers', []) as $provider) {
$event->sandbox->register($provider);
$resolved_providers[] = $event->sandbox->register($provider, boot: false);
}

// After all service providers have been registered, we will boot them.
foreach ($resolved_providers as $provider) {
$event->sandbox->bootProvider($provider);
}
}
}

0 comments on commit 6b7c52f

Please sign in to comment.