Explorar el Código

Ajustement UserMerchantBuilder

develop
Guillaume hace 11 meses
padre
commit
5e9add1eb3
Se han modificado 1 ficheros con 7 adiciones y 4 borrados
  1. +7
    -4
      Builder/User/UserMerchantBuilder.php

+ 7
- 4
Builder/User/UserMerchantBuilder.php Ver fichero

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

Cargando…
Cancelar
Guardar