Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions ListBuilder/DynamicListBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand All @@ -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());
}

/**
Expand All @@ -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
));
Expand Down
10 changes: 0 additions & 10 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down