Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOL-1287: do not overwrite exisisting technical name #678

Merged
merged 3 commits into from
Jan 10, 2024
Merged
Changes from 1 commit
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
27 changes: 14 additions & 13 deletions src/Service/PaymentMethodService.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@
$existingPaymentMethod = null;
}

$technicalName = '';

if ($existingPaymentMethod instanceof PaymentMethodEntity) {

Expand All @@ -183,19 +184,15 @@
'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')) {
BlackScorp marked this conversation as resolved.
Show resolved Hide resolved
$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();

Check failure on line 188 in src/Service/PaymentMethodService.php

View workflow job for this annotation

GitHub Actions / PHPStan

Call to an undefined method Shopware\Core\Checkout\Payment\PaymentMethodEntity::getTechnicalName().
BlackScorp marked this conversation as resolved.
Show resolved Hide resolved
} 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,
Expand All @@ -209,15 +206,19 @@
'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;
boxblinkracer marked this conversation as resolved.
Show resolved Hide resolved
}

$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) {
Expand Down
Loading