diff --git a/ListBuilder/DynamicListBuilder.php b/ListBuilder/DynamicListBuilder.php index cdd12516..5867e2d9 100644 --- a/ListBuilder/DynamicListBuilder.php +++ b/ListBuilder/DynamicListBuilder.php @@ -51,7 +51,7 @@ public function build(Dynamic $dynamic, string $locale): array foreach ($entry as $key => $value) { if (Dynamic::TYPE_ATTACHMENT === $dynamic->getFieldType($key)) { - $singleEntry[$key] = $this->getMediaUrls($value); + $singleEntry[$key] = $this->getMediaUrls($value, $locale); } else { $singleEntry[$key] = $this->toString($value); } @@ -95,15 +95,15 @@ private function toString($value): string /** * @param mixed $value */ - private function getMediaUrls($value): string + private function getMediaUrls($value, string $locale): string { if (\is_string($value)) { - return $this->getMediaUrl($value); + return $this->getMediaUrl($value, $locale); } if (\is_array($value)) { foreach ($value as $key => $mediaId) { - $value[$key] = $this->getMediaUrl($mediaId); + $value[$key] = $this->getMediaUrl($mediaId, $locale); } return \implode($this->delimiter, $value); @@ -112,9 +112,9 @@ private function getMediaUrls($value): string return $this->toString($value); } - private function getMediaUrl(string $value): string + private function getMediaUrl(string $value, string $locale): string { - return \str_replace('{id}', $value, $this->getDownloadUrl()); + return \str_replace(['{id}', '{locale}'], [$value, $locale], $this->getDownloadUrl()); } /** @@ -125,12 +125,13 @@ private function getDownloadUrl(): string if (null === $this->downloadUrl) { // The given id must be a number which we replace $idReplacerNumber = '875421'; + $localeToReplace = 'en'; - $this->downloadUrl = \str_replace($idReplacerNumber, '{id}', $this->router->generate( - 'sulu_media.website.media.download', + $this->downloadUrl = \str_replace([$idReplacerNumber, $localeToReplace], ['{id}', '{locale}'], $this->router->generate( + 'sulu_media.redirect', [ - 'slug' => 'file', 'id' => $idReplacerNumber, + 'locale' => $localeToReplace, ], RouterInterface::ABSOLUTE_URL )); diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index e2f04931..76e38710 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -40,11 +40,6 @@ parameters: count: 1 path: Command/FormGeneratorCommand.php - - - message: "#^Method Sulu\\\\Bundle\\\\FormBundle\\\\Command\\\\FormGeneratorCommand\\:\\:loadTestForm\\(\\) should return Sulu\\\\Bundle\\\\FormBundle\\\\Entity\\\\Form\\|null but returns mixed\\.$#" - count: 1 - path: Command/FormGeneratorCommand.php - - message: "#^Property Sulu\\\\Bundle\\\\FormBundle\\\\Configuration\\\\FormConfiguration\\:\\:\\$adminMailConfiguration \\(Sulu\\\\Bundle\\\\FormBundle\\\\Configuration\\\\MailConfigurationInterface\\) does not accept Sulu\\\\Bundle\\\\FormBundle\\\\Configuration\\\\MailConfigurationInterface\\|null\\.$#" count: 1 @@ -1385,11 +1380,6 @@ parameters: count: 2 path: Repository/FormRepository.php - - - message: "#^Method Sulu\\\\Bundle\\\\FormBundle\\\\Repository\\\\FormRepository\\:\\:loadById\\(\\) should return Sulu\\\\Bundle\\\\FormBundle\\\\Entity\\\\Form\\|null but returns mixed\\.$#" - count: 1 - path: Repository/FormRepository.php - - message: "#^Call to an undefined method Symfony\\\\Component\\\\HttpFoundation\\\\RequestStack\\:\\:getMasterRequest\\(\\)\\.$#" count: 1