Skip to content

[AssetMapper] Fix AssetMapper commands need http_client service #57336

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

Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
])

->set('asset_mapper.importmap.resolver', JsDelivrEsmResolver::class)
->args([service('http_client')])
->args([service('http_client')->nullOnInvalid()])

->set('asset_mapper.importmap.renderer', ImportMapRenderer::class)
->args([
Expand All @@ -212,12 +212,12 @@
->set('asset_mapper.importmap.auditor', ImportMapAuditor::class)
->args([
service('asset_mapper.importmap.config_reader'),
service('http_client'),
service('http_client')->nullOnInvalid(),
])
->set('asset_mapper.importmap.update_checker', ImportMapUpdateChecker::class)
->args([
service('asset_mapper.importmap.config_reader'),
service('http_client'),
service('http_client')->nullOnInvalid(),
])

->set('asset_mapper.importmap.command.require', ImportMapRequireCommand::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,20 @@

namespace Symfony\Component\AssetMapper\ImportMap;

use Symfony\Component\HttpClient\HttpClient;
use Symfony\Contracts\HttpClient\HttpClientInterface;

class ImportMapUpdateChecker
{
private const URL_PACKAGE_METADATA = 'https://registry.npmjs.org/%s';

private readonly HttpClientInterface $httpClient;

public function __construct(
private readonly ImportMapConfigReader $importMapConfigReader,
private readonly HttpClientInterface $httpClient,
?HttpClientInterface $httpClient = null,
) {
$this->httpClient = $httpClient ?? HttpClient::create();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was already suggested in #57073 which I considered to be a new feature (see #57073 (comment)).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok sorry i've lost my way after #57219 :(

(Maybe stupid idea) Could we, for Symfony 6.4 & 7.1, register a "fake" command (when http_client is not enabeld) that would display a message asking to enable http_client ?

Or would this be not worth it ?

As 6.4 is an LTS, i'm afraid of the number of people who could be impacted...
... but after all there is probably not that many people disabling http_client in framework bundle ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Maybe stupid idea) Could we, for Symfony 6.4 & 7.1, register a "fake" command (when http_client is not enabeld) that would display a message asking to enable http_client ?

That's exactly what I was thinking for the Symfony UX Icon search command :)

}

/**
Expand Down
Loading