[Asset] Fix JsonManifest when there is no dependency on HttpClient
This commit is contained in:
parent
d093475ce5
commit
e0e691a074
@ -77,7 +77,7 @@ return static function (ContainerConfigurator $container) {
|
||||
->abstract()
|
||||
->args([
|
||||
abstract_arg('manifest path'),
|
||||
service('http_client'),
|
||||
service('http_client')->nullOnInvalid(),
|
||||
])
|
||||
|
||||
->set('assets.remote_json_manifest_version_strategy', RemoteJsonManifestVersionStrategy::class)
|
||||
|
@ -61,6 +61,14 @@ class JsonManifestVersionStrategyTest extends TestCase
|
||||
$strategy->getVersion('main.js');
|
||||
}
|
||||
|
||||
public function testRemoteManifestFileWithoutHttpClient()
|
||||
{
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectExceptionMessage(sprintf('The "%s" class needs an HTTP client to use a remote manifest. Try running "composer require symfony/http-client".', JsonManifestVersionStrategy::class));
|
||||
|
||||
new JsonManifestVersionStrategy('https://cdn.example.com/manifest.json');
|
||||
}
|
||||
|
||||
public function provideValidStrategies()
|
||||
{
|
||||
yield from $this->provideStrategies('manifest-valid.json');
|
||||
|
@ -38,6 +38,10 @@ class JsonManifestVersionStrategy implements VersionStrategyInterface
|
||||
{
|
||||
$this->manifestPath = $manifestPath;
|
||||
$this->httpClient = $httpClient;
|
||||
|
||||
if (null === $this->httpClient && 0 === strpos(parse_url($this->manifestPath, \PHP_URL_SCHEME), 'http')) {
|
||||
throw new \LogicException(sprintf('The "%s" class needs an HTTP client to use a remote manifest. Try running "composer require symfony/http-client".', self::class));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user