Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e96c325

Browse filesBrowse files
committed
[Asset] Fix JsonManifest when there is no dependency on HttpClient
1 parent d093475 commit e96c325
Copy full SHA for e96c325

File tree

3 files changed

+13
-1
lines changed
Filter options

3 files changed

+13
-1
lines changed

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/assets.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/assets.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
->abstract()
7878
->args([
7979
abstract_arg('manifest path'),
80-
service('http_client'),
80+
service('http_client')->nullOnInvalid(),
8181
])
8282

8383
->set('assets.remote_json_manifest_version_strategy', RemoteJsonManifestVersionStrategy::class)

‎src/Symfony/Component/Asset/Tests/VersionStrategy/JsonManifestVersionStrategyTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Asset/Tests/VersionStrategy/JsonManifestVersionStrategyTest.php
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ public function testManifestFileWithBadJSONThrowsException(JsonManifestVersionSt
6161
$strategy->getVersion('main.js');
6262
}
6363

64+
public function testRemoteManifestFileWithoutHttpClient()
65+
{
66+
$this->expectException(\LogicException::class);
67+
$this->expectExceptionMessage(sprintf('The "%s" class need an HTTP client to use a remote manifest. Try running "composer require symfony/http-client".', JsonManifestVersionStrategy::class));
68+
69+
new JsonManifestVersionStrategy('https://cdn.example.com/manifest.json');
70+
}
71+
6472
public function provideValidStrategies()
6573
{
6674
yield from $this->provideStrategies('manifest-valid.json');

‎src/Symfony/Component/Asset/VersionStrategy/JsonManifestVersionStrategy.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Asset/VersionStrategy/JsonManifestVersionStrategy.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ public function __construct(string $manifestPath, HttpClientInterface $httpClien
3838
{
3939
$this->manifestPath = $manifestPath;
4040
$this->httpClient = $httpClient;
41+
42+
if (null === $this->httpClient && 0 === strpos(parse_url($this->manifestPath, \PHP_URL_SCHEME), 'http')) {
43+
throw new \LogicException(sprintf('The "%s" class need an HTTP client to use a remote manifest. Try running "composer require symfony/http-client".', self::class));
44+
}
4145
}
4246

4347
/**

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.