Skip to content
Code-Schnipsel Gruppen Projekte
Commit 19046b7b erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

fix(phpstan): ajax - improve null checking and function existence verification

Changes include:

1) In `removePos.php`, removed the usage of null safe method call, as it was not needed.
2) In `getOrderControl.php`, added a null guard before trying to get view from the OrderProcess and
use it. If the method does not exist, null will be assigned to `$View`.
3) Removed unnecessary fallback to get the first step in `getStep.php`. The current step is enough.
4) In `savePayment.php` added a check for the existence of 'savePayment' method before invoking it
to avoid possible errors.
5) The fallback to get the first step was also removed in `reload.php`.
6) Removed an unnecessary if condition in `send.php` and directly assigned current step's name to
`$current`.
7) In `setQuantity.php`, added a verification to check the existence of 'setQuantity' method before
calling it.

Related: #172
Übergeordneter afb39d80
No related branches found
No related tags found
2 Merge Requests!146fix: update `getCustomerFiles` method signature in `AbstractOrder`,!145Update 'next-3.x' with latest changes from 'main'
Pipeline #15533 fehlgeschlagen mit Phase
in 2 Minuten und 23 Sekunden
......@@ -15,7 +15,7 @@
function ($basketId, $pos) {
$User = QUI::getUserBySession();
$Basket = new QUI\ERP\Order\Basket\Basket($basketId, $User);
$Basket->getProducts()?->removePos($pos);
$Basket->getProducts()->removePos($pos);
QUI::getEvents()->fireEvent(
'quiqqerOrderBasketRemovePos',
......
......@@ -20,10 +20,15 @@ function ($orderHash) {
$Output = new QUI\Output();
$result = $OrderProcess->create();
$css = QUI\Control\Manager::getCSS();
$View = null;
if (method_exists($OrderProcess->getOrder(), 'getView')) {
$View = $OrderProcess->getOrder()->getView();
}
return [
'html' => $Output->parse($css . $result),
'data' => $OrderProcess->getOrder()->getView()->toArray()
'data' => $View?->toArray()
];
},
['orderHash']
......
......@@ -28,11 +28,6 @@ function ($orderId, $step, $orderHash, $basketEditable) {
]);
$Current = $OrderProcess->getCurrentStep();
if (!$Current) {
$Current = $OrderProcess->getFirstStep();
}
$OrderProcess->setAttribute('step', $Current->getName());
$html = $OrderProcess->create();
......
......@@ -22,12 +22,13 @@ function ($orderHash, $payment) {
'step' => $Processing->getName()
]);
/* @var $Processing Processing */
$Processing = $OrderProcess->getCurrentStep();
$Order = $OrderProcess->getOrder();
$Processing->setAttribute('Order', $Order);
$Processing->savePayment($payment);
if (method_exists($Processing, 'savePayment')) {
$Processing->savePayment($payment);
}
},
['orderHash', 'payment']
);
......@@ -25,10 +25,6 @@ function ($orderId, $step, $orderHash, $basketEditable) {
$Order = $OrderProcess->getOrder();
$Current = $OrderProcess->getCurrentStep();
if (!$Current) {
$Current = $OrderProcess->getFirstStep();
}
$OrderProcess->setAttribute('step', $Current->getName());
$OrderProcess->setAttribute('orderHash', $Order->getUUID());
......
......@@ -32,11 +32,7 @@ function ($current, $orderHash, $formData) {
]);
$result = $OrderProcess->create();
$current = false;
if ($OrderProcess->getCurrentStep()) {
$current = $OrderProcess->getCurrentStep()->getName();
}
$current = $OrderProcess->getCurrentStep()->getName();
return [
'html' => $result,
......
......@@ -30,7 +30,7 @@ function ($orderHash, $pos, $quantity) {
$Products = $Basket->getProducts();
$products = $Products->getProducts(); // get as array
if (isset($products[$pos])) {
if (isset($products[$pos]) && method_exists($products[$pos], 'setQuantity')) {
$products[$pos]->setQuantity($quantity);
}
......
0% oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren