Kaynağa Gözat

CreditUtils

feature/export_comptable
Guillaume 4 yıl önce
ebeveyn
işleme
4804c56b69
1 değiştirilmiş dosya ile 12 ekleme ve 4 silme
  1. +12
    -4
      ShopBundle/Services/CreditUtils.php

+ 12
- 4
ShopBundle/Services/CreditUtils.php Dosyayı Görüntüle

@@ -9,23 +9,31 @@ use Lc\ShopBundle\Context\MerchantUtilsInterface;
use Lc\ShopBundle\Context\UserInterface;
use Lc\ShopBundle\Context\UserMerchantInterface;
use Lc\ShopBundle\Model\CreditHistory;
use Symfony\Component\Security\Core\Security;

class CreditUtils
{
protected $em ;
protected $security ;
protected $merchantUtils ;
protected $userMerchantRepository ;

public function __construct(EntityManagerInterface $em, MerchantUtilsInterface $merchantUtils)
public function __construct(EntityManagerInterface $em, Security $security, MerchantUtilsInterface $merchantUtils)
{
$this->em = $em ;
$this->security = $security ;
$this->merchantUtils = $merchantUtils ;
$this->userMerchantRepository = $this->em->getRepository($this->em->getClassMetadata(UserMerchantInterface::class)->getName()) ;
}

public function getUserMerchant(UserInterface $user, MerchantInterface $merchant = null)
public function getUserMerchant(UserInterface $user = null, MerchantInterface $merchant = null)
{
if(!$user) {
$user = $this->security->getUser() ;
}

$merchant = $this->getMerchant($merchant) ;

$userMerchant = $this->userMerchantRepository->findOneBy([
'user' => $user,
'merchant' => $merchant
@@ -75,10 +83,10 @@ class CreditUtils
return $this->updateCreditActive($user, $merchant, false) ;
}

public function checkCreditActive(UserMerchantInterface $userMerchant)
public function checkCreditActive($userMerchant)
{
if(!$userMerchant || ($userMerchant && !$userMerchant->isCreditActive())) {
throw new \ErrorException("L'utilisateur n'a pas de compte prépayé activé pour ce marchand.") ;
return false ;
}

return true ;

Yükleniyor…
İptal
Kaydet