Переглянути джерело

Ajustement UserMerchantBuilder

develop
Guillaume 11 місяці тому
джерело
коміт
5e9add1eb3
1 змінених файлів з 7 додано та 4 видалено
  1. +7
    -4
      Builder/User/UserMerchantBuilder.php

+ 7
- 4
Builder/User/UserMerchantBuilder.php Переглянути файл

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

Завантаження…
Відмінити
Зберегти