Sfoglia il codice sorgente

Refactoring CartController::addProductFamily() #299

develop
Guillaume Bourgeois 2 anni fa
parent
commit
79a79fb7d9
1 ha cambiato i file con 7 aggiunte e 2 eliminazioni
  1. +7
    -2
      Controller/Order/CartController.php

+ 7
- 2
Controller/Order/CartController.php Vedi File

@@ -21,7 +21,6 @@ class CartController extends AbstractController
protected int $quantityOrder = 1;
protected array $orderProducts = [];

//TODO Refactorer cette méthode ligne 48 return false !!! Pas possible, de plus elle retourne un json vide ...
public function addProductFamily(Request $request): JsonResponse
{
$user = $this->getUserCurrent();
@@ -34,6 +33,10 @@ class CartController extends AbstractController
$idProductFamily = $data['order_products']['id_product_family'];
$this->productFamily = $this->getProductFamilyContainer()->getStore()->getOneById($idProductFamily);

if(!$this->productFamily) {
$return['return'] = 'error';
}

// alerte si cookies non acceptés
if (!$user && !$visitor) {
$this->addFlash(
@@ -45,7 +48,7 @@ class CartController extends AbstractController
'fos_user_security_login'
) . '">connecter</a> pour ajouter un produit.'
);
return false;
$return['return'] = 'error';
}

if ($this->productFamily) {
@@ -69,6 +72,8 @@ class CartController extends AbstractController
$this->addOrderProduct($orderShop, $orderProduct);
}
}

$return['return'] = 'success';
}
}
}

Loading…
Annulla
Salva