Procházet zdrojové kódy

Correctifs EntityManager + OrderUtils

develop
Guillaume před 3 roky
rodič
revize
f95ac54371
2 změnil soubory, kde provedl 30 přidání a 7 odebrání
  1. +14
    -2
      ShopBundle/Manager/EntityManager.php
  2. +16
    -5
      ShopBundle/Services/Order/OrderUtilsReductionTrait.php

+ 14
- 2
ShopBundle/Manager/EntityManager.php Zobrazit soubor

@@ -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 Zobrazit soubor

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



Načítá se…
Zrušit
Uložit