Skip to content

Commit

Permalink
add additional checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim Solovev committed Jun 14, 2024
1 parent f10afcb commit e9e64bf
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/DependencyInjection/HttplugExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Http\Client\Common\HttpMethodsClient;
use Http\Client\Common\HttpMethodsClientInterface;
use Http\Client\Common\Plugin\AuthenticationPlugin;
use Http\Client\Common\Plugin\ThrottlePlugin;
use Http\Client\Common\PluginClient;
use Http\Client\Common\PluginClientFactory;
use Http\Client\HttpAsyncClient;
Expand Down Expand Up @@ -294,6 +295,14 @@ private function configurePluginByName($name, Definition $definition, array $con
break;

case 'throttle':
if (!\interface_exists(LimiterInterface::class)) {
throw new InvalidConfigurationException('You need to require the Rate Limiter to be able to use it: "composer require symfony/rate-limiter".');
}

if (!\class_exists(ThrottlePlugin::class)) {
throw new InvalidConfigurationException('You need to require the Throttle Plugin to be able to use it: "composer require php-http/throttle-plugin".');
}

$key = $config['name'] ? '.'.$config['name'] : '';
$container
->register($serviceId.$key, LimiterInterface::class)
Expand Down

0 comments on commit e9e64bf

Please sign in to comment.