Browse Source

Ajustement UserMerchantBuilder

develop
Guillaume 1 year ago
parent
commit
5e9add1eb3
1 changed files with 7 additions and 4 deletions
  1. +7
    -4
      Builder/User/UserMerchantBuilder.php

+ 7
- 4
Builder/User/UserMerchantBuilder.php View File

@@ -23,7 +23,7 @@ class UserMerchantBuilder
$this->userMerchantStore = $userMerchantStore;
}

public function createIfNotExist(UserInterface $user, MerchantInterface $merchant): UserMerchantInterface
public function createIfNotExist(UserInterface $user, MerchantInterface $merchant, $flush = true): UserMerchantInterface
{
$userMerchant = $this->userMerchantStore
->setMerchant($merchant)
@@ -32,13 +32,16 @@ class UserMerchantBuilder
if (!$userMerchant) {
$userMerchantFactory = new UserMerchantFactory();
$userMerchant = $userMerchantFactory->create($merchant, $user);

$this->entityManager->create($userMerchant);
$this->entityManager->flush();
if($flush) {
$this->entityManager->flush();
}
}elseif(!$userMerchant->getActive()){
$userMerchant->setActive(true);
$this->entityManager->update($userMerchant);
$this->entityManager->flush();
if($flush) {
$this->entityManager->flush();
}
}

return $userMerchant;

Loading…
Cancel
Save