From b6c37f4f2380b58c30536a56339129063576c0a0 Mon Sep 17 00:00:00 2001 From: Thijs De Paepe Date: Fri, 22 Sep 2023 11:16:53 +0200 Subject: [PATCH] added: default value-separator --- .../AttributeFormatter/MultiValuePresenterFormatter.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Component/AttributeFormatter/MultiValuePresenterFormatter.php b/src/Component/AttributeFormatter/MultiValuePresenterFormatter.php index 81e582fb..c07123b5 100644 --- a/src/Component/AttributeFormatter/MultiValuePresenterFormatter.php +++ b/src/Component/AttributeFormatter/MultiValuePresenterFormatter.php @@ -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; } @@ -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'])) {