diff --git a/src/Core/Media/MediaUrlGenerator.php b/src/Core/Media/MediaUrlGenerator.php index 21a493c..7969720 100644 --- a/src/Core/Media/MediaUrlGenerator.php +++ b/src/Core/Media/MediaUrlGenerator.php @@ -18,7 +18,7 @@ class MediaUrlGenerator extends AbstractMediaUrlGenerator public function __construct( private readonly AbstractMediaUrlGenerator $mediaUrlGenerator, private readonly ThumbnailUrlTemplateInterface $thumbnailUrlTemplate, - private readonly FilesystemOperator $filesystem, + private readonly FilesystemOperator $publicFilesystem, private readonly ConfigReader $configReader ) { } @@ -80,7 +80,7 @@ private function canProcessFileExtension(string $fileExtension): bool private function getBaseUrl(): string { - return \rtrim($this->filesystem->publicUrl(''), '/'); + return \rtrim($this->publicFilesystem->publicUrl(''), '/'); } /** diff --git a/src/Core/Media/MediaUrlLoader.php b/src/Core/Media/MediaUrlLoader.php index 47f2fad..464a392 100644 --- a/src/Core/Media/MediaUrlLoader.php +++ b/src/Core/Media/MediaUrlLoader.php @@ -4,10 +4,10 @@ use Shopware\Core\Framework\DataAbstractionLayer\Entity; -class MediaUrlLoader +readonly class MediaUrlLoader { public function __construct( - private readonly MediaUrlGenerator $generator + private MediaUrlGenerator $generator ) { } diff --git a/src/Resources/config/services.xml b/src/Resources/config/services.xml index a5b4f8a..12b4f3e 100644 --- a/src/Resources/config/services.xml +++ b/src/Resources/config/services.xml @@ -50,5 +50,9 @@ + + + diff --git a/src/Storefront/Framework/Twig/Extension/UrlEncodingTwigFilter.php b/src/Storefront/Framework/Twig/Extension/UrlEncodingTwigFilter.php new file mode 100644 index 0000000..c09fa40 --- /dev/null +++ b/src/Storefront/Framework/Twig/Extension/UrlEncodingTwigFilter.php @@ -0,0 +1,22 @@ +createMock(AbstractMediaUrlGenerator::class); @@ -293,4 +294,4 @@ public static function provideAllowedExtensions(): iterable yield ['gif,png']; yield ['']; } -} \ No newline at end of file +} diff --git a/tests/unit/Core/Media/MediaUrlLoaderTest.php b/tests/unit/Core/Media/MediaUrlLoaderTest.php index 670d008..eb3c508 100644 --- a/tests/unit/Core/Media/MediaUrlLoaderTest.php +++ b/tests/unit/Core/Media/MediaUrlLoaderTest.php @@ -264,4 +264,4 @@ public static function provideInvalidThumbnailData(): iterable yield [['']]; yield [new PartialEntity()]; } -} \ No newline at end of file +} diff --git a/tests/unit/Service/ConfigReaderTest.php b/tests/unit/Service/ConfigReaderTest.php index 8f72578..bc53bf1 100644 --- a/tests/unit/Service/ConfigReaderTest.php +++ b/tests/unit/Service/ConfigReaderTest.php @@ -107,7 +107,7 @@ public function testGetConfigActiveWithActiveTest(): void } /** - * @return iterable + * @return iterable */ public static function getSalesChannelIds(): iterable { @@ -129,7 +129,7 @@ public static function getWidths(): iterable } /** - * @return iterable + * @return iterable */ public static function getActiveValues(): iterable { diff --git a/tests/unit/Storefront/Framework/Twig/Extension/UrlEncodingTwigFilterTest.php b/tests/unit/Storefront/Framework/Twig/Extension/UrlEncodingTwigFilterTest.php new file mode 100644 index 0000000..adb9d74 --- /dev/null +++ b/tests/unit/Storefront/Framework/Twig/Extension/UrlEncodingTwigFilterTest.php @@ -0,0 +1,23 @@ +encodeUrl('https://example.com/w:1/image.jpg'); + static::assertSame('https://example.com/w:1/image.jpg', $result); + } + + public function testEncodeUrlNull(): void + { + $urlEncodingTwigFilter = new UrlEncodingTwigFilter(); + $result = $urlEncodingTwigFilter->encodeUrl(null); + static::assertNull($result); + } +} \ No newline at end of file