Преглед изворни кода

[Place du Local] [ERREUR 500] Ce produit est introuvable #669

develop
Guillaume Bourgeois пре 1 година
родитељ
комит
9bba757665
1 измењених фајлова са 11 додато и 11 уклоњено
  1. +11
    -11
      Controller/Product/FavoriteController.php

+ 11
- 11
Controller/Product/FavoriteController.php Прегледај датотеку

@@ -15,9 +15,9 @@ class FavoriteController extends AbstractController
public function toggle(Request $request)
{
$user = $this->getUserCurrent();
if($user) {
$productFamily = $this->_getProductFamily($request);
$productFamily = $this->_getProductFamily($request);

if($user && $productFamily) {
if ($user->getFavoriteProductFamilies()->contains($productFamily)) {
$user->removeFavoriteProductFamily($productFamily);
$isFavorite = false;
@@ -37,7 +37,7 @@ class FavoriteController extends AbstractController
]);
}
else {
return $this->_errorUserNotConnected();
return $this->_errorResponse();
}
}

@@ -47,9 +47,9 @@ class FavoriteController extends AbstractController
public function add(Request $request)
{
$user = $this->getUserCurrent();
if($user) {
$productFamily = $this->_getProductFamily($request);
$productFamily = $this->_getProductFamily($request);

if($user && $productFamily) {
$user->addFavoriteProductFamily($productFamily);
$this->_saveUser($user);

@@ -59,7 +59,7 @@ class FavoriteController extends AbstractController
]);
}
else {
return $this->_errorUserNotConnected();
return $this->_errorResponse();
}
}

@@ -69,9 +69,9 @@ class FavoriteController extends AbstractController
public function delete(Request $request)
{
$user = $this->getUserCurrent();
if($user) {
$productFamily = $this->_getProductFamily($request);
$productFamily = $this->_getProductFamily($request);

if($user && $productFamily) {
$user->removeFavoriteProductFamily($productFamily);
$this->_saveUser($user);

@@ -81,7 +81,7 @@ class FavoriteController extends AbstractController
]);
}
else {
return $this->_errorUserNotConnected();
return $this->_errorResponse();
}
}

@@ -105,11 +105,11 @@ class FavoriteController extends AbstractController
}
}

private function _errorUserNotConnected()
private function _errorResponse()
{
return new JsonResponse([
'return' => 'error',
'message' => 'Vous devez être connecté pour gérer vos favoris.'
'message' => 'Une erreur est survenue.'
]);
}
}

Loading…
Откажи
Сачувај