10000 [FrameworkBundle] Add scoped httplug clients and deprecate httplugs use like psr18 client by simonberger · Pull Request #49691 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
8000

[FrameworkBundle] Add scoped httplug clients and deprecate httplugs use like psr18 client #49691

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
Mar 16, 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
1 change: 1 addition & 0 deletions UPGRADE-6.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ FrameworkBundle
---------------

* Deprecate the `notifier.logger_notification_listener` service, use the `notifier.notification_logger_listener` service instead
* Deprecate the `Http\Client\HttpClient` service, use `Psr\Http\Client\ClientInterface` instead

HttpFoundation
--------------
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ CHANGELOG
* Add `framework.http_cache.skip_response_headers` option
* Display warmers duration on debug verbosity for `cache:clear` command
* Add `AbstractController::sendEarlyHints()` to send HTTP Early Hints
* Add autowiring aliases for `Http\Client\HttpAsyncClient`
* Deprecate the `Http\Client\HttpClient` service, use `Psr\Http\Client\ClientInterface` instead

6.2
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Composer\InstalledVersions;
use Doctrine\Common\Annotations\Reader;
use Http\Client\HttpAsyncClient;
use Http\Client\HttpClient;
use phpDocumentor\Reflection\DocBlockFactoryInterface;
use phpDocumentor\Reflection\Types\ContextFactory;
Expand Down Expand Up @@ -2354,8 +2355,10 @@ private function registerHttpClientConfiguration(array $config, ContainerBuilder
$container->removeAlias(ClientInterface::class);
}

if (!ContainerBuilder::willBeAvailable('php-http/httplug', HttpClient::class, ['symfony/framework-bundle', 'symfony/http-client'])) {
$container->removeDefinition(HttpClient::class);
if (!$hasHttplug = ContainerBuilder::willBeAvailable('php-http/httplug', HttpAsyncClient::class, ['symfony/framework-bundle', 'symfony/http-client'])) {
$container->removeDefinition('httplug.http_client');
$container->removeAlias(HttpAsyncClient::class);
$container->removeAlias(HttpClient::class);
}

if ($this->readConfigEnabled('http_client.retry_failed', $container, $retryOptions)) {
Expand Down Expand Up @@ -2425,6 +2428,13 @@ private function registerHttpClientConfiguration(array $config, ContainerBuilder

$container->registerAliasForArgument('psr18.'.$name, ClientInterface::class, $name);
}

if ($hasHttplug) {
$container->setDefinition('httplug.'.$name, new ChildDefinition('httplug.http_client'))
->replaceArgument(0, new Reference($name));

$container->registerAliasForArgument('httplug.'.$name, HttpAsyncClient::class, $name);
}
}

if ($responseFactoryId = $config['mock_response_factory'] ?? null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use Http\Client\HttpAsyncClient;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\StreamFactoryInterface;
Expand Down Expand Up @@ -49,13 +50,17 @@

->alias(ClientInterface::class, 'psr18.http_client')

->set(\Http\Client\HttpClient::class, HttplugClient::class)
->set('httplug.http_client', HttplugClient::class)
->args([
service('http_client'),
service(ResponseFactoryInterface::class)->ignoreOnInvalid(),
service(StreamFactoryInterface::class)->ignoreOnInvalid(),
])

->alias(HttpAsyncClient::class, 'httplug.http_client')
->alias(\Http\Client\HttpClient::class, 'httplug.http_client')
->deprecate('symfony/framework-bundle', '6.3', 'The "%alias_id%" service is deprecated, use "'.ClientInterface::class.'" instead.')

->set('http_client.abstract_retry_strategy', GenericRetryStrategy::class)
->abstract()
->args([
Expand Down
0