Bladeren bron

Correctifs EntityManager + OrderUtils

develop
Guillaume 3 jaren geleden
bovenliggende
commit
f95ac54371
2 gewijzigde bestanden met toevoegingen van 30 en 7 verwijderingen
  1. +14
    -2
      ShopBundle/Manager/EntityManager.php
  2. +16
    -5
      ShopBundle/Services/Order/OrderUtilsReductionTrait.php

+ 14
- 2
ShopBundle/Manager/EntityManager.php Bestand weergeven

@@ -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 Bestand weergeven

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



Laden…
Annuleren
Opslaan