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