Browse Source

Correctifs EntityManager + OrderUtils

develop
Guillaume 3 years ago
parent
commit
f95ac54371
2 changed files with 30 additions and 7 deletions
  1. +14
    -2
      ShopBundle/Manager/EntityManager.php
  2. +16
    -5
      ShopBundle/Services/Order/OrderUtilsReductionTrait.php

+ 14
- 2
ShopBundle/Manager/EntityManager.php View File

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 View File



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





Loading…
Cancel
Save