Quellcode durchsuchen

Correctifs EntityManager + OrderUtils

develop
Guillaume vor 3 Jahren
Ursprung
Commit
f95ac54371
2 geänderte Dateien mit 30 neuen und 7 gelöschten Zeilen
  1. +14
    -2
      ShopBundle/Manager/EntityManager.php
  2. +16
    -5
      ShopBundle/Services/Order/OrderUtilsReductionTrait.php

+ 14
- 2
ShopBundle/Manager/EntityManager.php Datei anzeigen

return $this; return $this;
} }


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

return $this ;
}

public function flush(): self public function flush(): self
{ {
$this->entityManager->flush(); $this->entityManager->flush();
{ {
$this->entityManager->refresh($entity); $this->entityManager->refresh($entity);
} }
public function getClassMetadata($className)
{
return $this->entityManager->getClassMetadata($className) ;
}


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

} }
} }

+ 16
- 5
ShopBundle/Services/Order/OrderUtilsReductionTrait.php Datei anzeigen



$orderShop->addOrderReductionCart($orderReductionCart) ; $orderShop->addOrderReductionCart($orderReductionCart) ;


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

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

return $orderReductionCart ; return $orderReductionCart ;
} }

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


public function isReductionCreditAllowAddToOrder($orderShop, $reductionCredit) public function isReductionCreditAllowAddToOrder($orderShop, $reductionCredit)


$orderShop->addOrderReductionCredit($orderReductionCredit) ; $orderShop->addOrderReductionCredit($orderReductionCredit) ;


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

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

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


return false ;
return false;
}
} }





Laden…
Abbrechen
Speichern