Skip to content

Commit

Permalink
added: default value-separator
Browse files Browse the repository at this point in the history
  • Loading branch information
Thijzer committed Sep 22, 2023
1 parent a6ca37d commit b6c37f4
Showing 1 changed file with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@ class MultiValuePresenterFormatter implements PropertyFormatterInterface, Requir
*/
public function format($value, array $context = [])
{
$valueSeparator = $context['value-separator'] ?? ', '; # best fallback option
if ($context['current-attribute-type'] === 'pim_catalog_multiselect' && empty($value)) {
return '';
}

if ($context['current-attribute-type'] === 'pim_catalog_multiselect' && is_array($value)) {
return implode(',', $value);
}

if (empty($value)) {
return $value;
}
Expand All @@ -31,8 +28,8 @@ public function format($value, array $context = [])
return ValueFormatter::format($value['format'], $value);
}

if (is_array($value) && !isset($value['format']) && isset($context['value-separator'])) {
$value = implode($context['value-separator'], $value);
if (is_array($value) && !isset($value['format']) && isset($valueSeparator)) {
$value = implode($valueSeparator, $value);
}

if (is_string($value) && isset($context['format'])) {
Expand Down

0 comments on commit b6c37f4

Please sign in to comment.