diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/assets.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/assets.php index a6f278743a75f..d4418ed75734b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/assets.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/assets.php @@ -18,7 +18,6 @@ use Symfony\Component\Asset\UrlPackage; use Symfony\Component\Asset\VersionStrategy\EmptyVersionStrategy; use Symfony\Component\Asset\VersionStrategy\JsonManifestVersionStrategy; -use Symfony\Component\Asset\VersionStrategy\RemoteJsonManifestVersionStrategy; use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy; return static function (ContainerConfigurator $container) { @@ -81,13 +80,5 @@ abstract_arg('manifest path'), service('http_client')->nullOnInvalid(), ]) - - ->set('assets.remote_json_manifest_version_strategy', RemoteJsonManifestVersionStrategy::class) - ->abstract() - ->deprecate('symfony/framework-bundle', '5.3', 'The "%service_id%" service is deprecated, use "assets.json_manifest_version_strategy" instead.') - ->args([ - abstract_arg('manifest url'), - service('http_client'), - ]) ; }; diff --git a/src/Symfony/Component/Asset/CHANGELOG.md b/src/Symfony/Component/Asset/CHANGELOG.md index 330be1f7c70c7..6aeea256ea13a 100644 --- a/src/Symfony/Component/Asset/CHANGELOG.md +++ b/src/Symfony/Component/Asset/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +6.0 +--- + +* Remove `RemoteJsonManifestVersionStrategy`, use `JsonManifestVersionStrategy` instead + 5.3 --- diff --git a/src/Symfony/Component/Asset/Tests/VersionStrategy/RemoteJsonManifestVersionStrategyTest.php b/src/Symfony/Component/Asset/Tests/VersionStrategy/RemoteJsonManifestVersionStrategyTest.php deleted file mode 100644 index 7382cffddeb28..0000000000000 --- a/src/Symfony/Component/Asset/Tests/VersionStrategy/RemoteJsonManifestVersionStrategyTest.php +++ /dev/null @@ -1,76 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Asset\Tests\VersionStrategy; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Asset\VersionStrategy\RemoteJsonManifestVersionStrategy; -use Symfony\Component\HttpClient\Exception\JsonException; -use Symfony\Component\HttpClient\MockHttpClient; -use Symfony\Component\HttpClient\Response\MockResponse; - -/** - * @group legacy - */ -class RemoteJsonManifestVersionStrategyTest extends TestCase -{ - public function testGetVersion() - { - $strategy = $this->createStrategy('https://cdn.example.com/manifest-valid.json'); - - $this->assertSame('main.123abc.js', $strategy->getVersion('main.js')); - } - - public function testApplyVersion() - { - $strategy = $this->createStrategy('https://cdn.example.com/manifest-valid.json'); - - $this->assertSame('css/styles.555def.css', $strategy->applyVersion('css/styles.css')); - } - - public function testApplyVersionWhenKeyDoesNotExistInManifest() - { - $strategy = $this->createStrategy('https://cdn.example.com/manifest-valid.json'); - - $this->assertSame('css/other.css', $strategy->applyVersion('css/other.css')); - } - - public function testMissingManifestFileThrowsException() - { - $this->expectException(\RuntimeException::class); - $this->expectExceptionMessage('HTTP 404 returned for "https://cdn.example.com/non-existent-file.json"'); - $strategy = $this->createStrategy('https://cdn.example.com/non-existent-file.json'); - $strategy->getVersion('main.js'); - } - - public function testManifestFileWithBadJSONThrowsException() - { - $this->expectException(JsonException::class); - $this->expectExceptionMessage('Syntax error'); - $strategy = $this->createStrategy('https://cdn.example.com/manifest-invalid.json'); - $strategy->getVersion('main.js'); - } - - private function createStrategy($manifestUrl) - { - $httpClient = new MockHttpClient(function ($method, $url, $options) { - $filename = __DIR__.'/../fixtures/'.basename($url); - - if (file_exists($filename)) { - return new MockResponse(file_get_contents($filename), ['http_headers' => ['content-type' => 'application/json']]); - } - - return new MockResponse('{}', ['http_code' => 404]); - }); - - return new RemoteJsonManifestVersionStrategy($manifestUrl, $httpClient); - } -} diff --git a/src/Symfony/Component/Asset/VersionStrategy/RemoteJsonManifestVersionStrategy.php b/src/Symfony/Component/Asset/VersionStrategy/RemoteJsonManifestVersionStrategy.php deleted file mode 100644 index cc6170a27e4c2..0000000000000 --- a/src/Symfony/Component/Asset/VersionStrategy/RemoteJsonManifestVersionStrategy.php +++ /dev/null @@ -1,66 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Asset\VersionStrategy; - -use Symfony\Contracts\HttpClient\HttpClientInterface; - -trigger_deprecation('symfony/asset', '5.3', 'The "%s" class is deprecated, use "%s" instead.', RemoteJsonManifestVersionStrategy::class, JsonManifestVersionStrategy::class); - -/** - * Reads the versioned path of an asset from a remote JSON manifest file. - * - * For example, the manifest file might look like this: - * { - * "main.js": "main.abc123.js", - * "css/styles.css": "css/styles.555abc.css" - * } - * - * You could then ask for the version of "main.js" or "css/styles.css". - * - * @deprecated since Symfony 5.3, use JsonManifestVersionStrategy instead. - */ -class RemoteJsonManifestVersionStrategy implements VersionStrategyInterface -{ - private $manifestData; - private $manifestUrl; - private $httpClient; - - /** - * @param string $manifestUrl Absolute URL to the manifest file - */ - public function __construct(string $manifestUrl, HttpClientInterface $httpClient) - { - $this->manifestUrl = $manifestUrl; - $this->httpClient = $httpClient; - } - - /** - * With a manifest, we don't really know or care about what - * the version is. Instead, this returns the path to the - * versioned file. - */ - public function getVersion(string $path) - { - return $this->applyVersion($path); - } - - public function applyVersion(string $path) - { - if (null === $this->manifestData) { - $this->manifestData = $this->httpClient->request('GET', $this->manifestUrl, [ - 'headers' => ['accept' => 'application/json'], - ])->toArray(); - } - - return $this->manifestData[$path] ?? $path; - } -} diff --git a/src/Symfony/Component/Asset/composer.json b/src/Symfony/Component/Asset/composer.json index b05cf6f79607a..e4654f91ec06c 100644 --- a/src/Symfony/Component/Asset/composer.json +++ b/src/Symfony/Component/Asset/composer.json @@ -16,8 +16,7 @@ } ], "require": { - "php": ">=8.0.2", - "symfony/deprecation-contracts": "^2.1" + "php": ">=8.0.2" }, "suggest": { "symfony/http-foundation": ""