Skip to content

Fix: Always provide bootstrap provider #47

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

Merged
merged 1 commit into from
Nov 28, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/DependencyInjection/Compiler/BootstrapResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Unleash\Client\Bootstrap\EmptyBootstrapProvider;
use Unleash\Client\Bootstrap\FileBootstrapProvider;

/**
Expand Down Expand Up @@ -37,6 +38,8 @@ private function registerTaggedService(ContainerBuilder $container): void
{
$serviceIds = array_keys($container->findTaggedServiceIds(self::TAG));
if (!count($serviceIds)) {
$this->registerEmptyService($container);

return;
}

Expand All @@ -61,4 +64,10 @@ private function registerServiceService(string $serviceId, ContainerBuilder $con
{
$container->setAlias(self::INTERNAL_SERVICE_NAME, $serviceId);
}

private function registerEmptyService(ContainerBuilder $container): void
{
$definition = new Definition(EmptyBootstrapProvider::class);
$container->setDefinition(self::INTERNAL_SERVICE_NAME, $definition);
}
}
2 changes: 1 addition & 1 deletion src/Resources/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ services:
$headers: '%unleash.client.internal.custom_headers%'
$autoRegistrationEnabled: '%unleash.client.internal.auto_registration%'
$contextProvider: '@unleash.client.internal.context_provider'
$bootstrapProvider: '@?unleash.client.internal.bootstrap_service'
$bootstrapProvider: '@unleash.client.internal.bootstrap_service'
$fetchingEnabled: '%unleash.client.internal.fetching_enabled%'
$eventDispatcher: '@event_dispatcher'
$staleTtl: '%unleash.client.internal.stale_ttl%'
Expand Down