Преглед на файлове

Correctifs EntityManager + OrderUtils

develop
Guillaume преди 3 години
родител
ревизия
f95ac54371
променени са 2 файла, в които са добавени 30 реда и са изтрити 7 реда
  1. +14
    -2
      ShopBundle/Manager/EntityManager.php
  2. +16
    -5
      ShopBundle/Services/Order/OrderUtilsReductionTrait.php

+ 14
- 2
ShopBundle/Manager/EntityManager.php Целия файл

@@ -79,6 +79,13 @@ class EntityManager
return $this;
}

public function remove($entity): self
{
$this->entityManager->remove($entity) ;

return $this ;
}

public function flush(): self
{
$this->entityManager->flush();
@@ -102,14 +109,19 @@ class EntityManager
{
$this->entityManager->refresh($entity);
}
public function getClassMetadata($className)
{
return $this->entityManager->getClassMetadata($className) ;
}

public function getEntityName($className)
{
if (substr($className, -9) === 'Interface') {
return $this->entityManager->getClassMetadata($className)->getName();
} else {
}
else {
return $className;
}

}
}

+ 16
- 5
ShopBundle/Services/Order/OrderUtilsReductionTrait.php Целия файл

@@ -73,13 +73,18 @@ trait OrderUtilsReductionTrait

$orderShop->addOrderReductionCart($orderReductionCart) ;

if($this->isOrderShopPositiveAmount($orderShop)) {
if($this->isOrderShopPositiveAmount($orderShop)
&& $this->isOrderShopPositiveAmountRemainingToBePaid($orderShop)) {

$this->em->persist($orderReductionCart);
$this->em->flush();

return $orderReductionCart ;
}

return false;
else {
$orderShop->removeOrderReductionCart($orderReductionCart) ;
return false;
}
}

public function isReductionCreditAllowAddToOrder($orderShop, $reductionCredit)
@@ -148,13 +153,19 @@ trait OrderUtilsReductionTrait

$orderShop->addOrderReductionCredit($orderReductionCredit) ;

if($this->isOrderShopPositiveAmount($orderShop)) {
if($this->isOrderShopPositiveAmount($orderShop)
&& $this->isOrderShopPositiveAmountRemainingToBePaid($orderShop)) {

$this->em->persist($orderReductionCredit);
$this->em->flush();

return $orderReductionCredit;
}
else {
$orderShop->removeOrderReductionCredit($orderReductionCredit) ;

return false ;
return false;
}
}



Loading…
Отказ
Запис