Переглянути джерело

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;
}
}



Завантаження…
Відмінити
Зберегти