From ea2e12c66bd96c95a50742a1ff1bdb799827c15a Mon Sep 17 00:00:00 2001 From: Vitalij Mik Date: Wed, 10 Jan 2024 08:12:08 +0100 Subject: [PATCH 1/3] MOL-1287: do not overwrite exisisting technical name --- src/Service/PaymentMethodService.php | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/Service/PaymentMethodService.php b/src/Service/PaymentMethodService.php index e1f2da903..1e52f6cdf 100644 --- a/src/Service/PaymentMethodService.php +++ b/src/Service/PaymentMethodService.php @@ -159,6 +159,7 @@ public function addPaymentMethods(array $paymentMethods, Context $context): void $existingPaymentMethod = null; } + $technicalName = ''; if ($existingPaymentMethod instanceof PaymentMethodEntity) { @@ -183,19 +184,15 @@ public function addPaymentMethods(array $paymentMethods, Context $context): void 'name' => $existingPaymentMethod->getName(), ]; - # starting with Shopware 6.5.7.0 this has to be filled out - # so that you can still save the payment method in the administration - if ($this->versionCompare->gte('6.5.7.0')) { - $paymentMethodData['technicalName'] = self::TECHNICAL_NAME_PREFIX . $mollieName; - } - - $upsertData[] = $paymentMethodData; + # we do a string cast here, since getTechnicalName will be not nullable in the future + $technicalName = (string)$existingPaymentMethod->getTechnicalName(); } else { # let's create a full parameter list of everything # that our new payment method needs to have $mollieName = $paymentMethod['description']; + $paymentMethodData = [ 'handlerIdentifier' => $paymentMethod['handler'], 'pluginId' => $pluginId, @@ -209,15 +206,19 @@ public function addPaymentMethods(array $paymentMethods, Context $context): void 'mollie_payment_method_name' => $mollieName ], ]; + } - # starting with Shopware 6.5.7.0 this has to be filled out - # so that you can still save the payment method in the administration - if ($this->versionCompare->gte('6.5.7.0')) { - $paymentMethodData['technicalName'] = self::TECHNICAL_NAME_PREFIX . $mollieName; - } + if (mb_strlen($technicalName) > 0) { + $technicalName = self::TECHNICAL_NAME_PREFIX . $mollieName; + } - $upsertData[] = $paymentMethodData; + # starting with Shopware 6.5.7.0 this has to be filled out + # so that you can still save the payment method in the administration + if ($this->versionCompare->gte('6.5.7.0')) { + $paymentMethodData['technicalName'] = $technicalName; } + + $upsertData[] = $paymentMethodData; } if (count($upsertData) > 0) { From 8afecd9e43f20f288a32fae6d8560e322a5d7b13 Mon Sep 17 00:00:00 2001 From: Vitalij Mik Date: Wed, 10 Jan 2024 08:19:36 +0100 Subject: [PATCH 2/3] MOL-1287: technical name in 6.5.7 --- src/Service/PaymentMethodService.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Service/PaymentMethodService.php b/src/Service/PaymentMethodService.php index 1e52f6cdf..7dd5ff7b5 100644 --- a/src/Service/PaymentMethodService.php +++ b/src/Service/PaymentMethodService.php @@ -184,8 +184,11 @@ public function addPaymentMethods(array $paymentMethods, Context $context): void 'name' => $existingPaymentMethod->getName(), ]; - # we do a string cast here, since getTechnicalName will be not nullable in the future - $technicalName = (string)$existingPaymentMethod->getTechnicalName(); + if ($this->versionCompare->gte('6.5.7.0')) { + # we do a string cast here, since getTechnicalName will be not nullable in the future + $technicalName = (string)$existingPaymentMethod->getTechnicalName(); + } + } else { # let's create a full parameter list of everything # that our new payment method needs to have From 0ff50912e7e123e1f28281e0259e1ca47c7263c3 Mon Sep 17 00:00:00 2001 From: Vitalij Mik Date: Wed, 10 Jan 2024 09:01:45 +0100 Subject: [PATCH 3/3] MOL-1287: cs and stan fix --- src/Service/PaymentMethodService.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Service/PaymentMethodService.php b/src/Service/PaymentMethodService.php index 7dd5ff7b5..afe30336c 100644 --- a/src/Service/PaymentMethodService.php +++ b/src/Service/PaymentMethodService.php @@ -186,9 +186,8 @@ public function addPaymentMethods(array $paymentMethods, Context $context): void if ($this->versionCompare->gte('6.5.7.0')) { # we do a string cast here, since getTechnicalName will be not nullable in the future - $technicalName = (string)$existingPaymentMethod->getTechnicalName(); + $technicalName = (string)$existingPaymentMethod->getTechnicalName(); /** @phpstan-ignore-line */ } - } else { # let's create a full parameter list of everything # that our new payment method needs to have