@@ -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; |
@@ -263,8 +263,13 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
public function __construct() | |||
{ | |||
$this->productCategories = new ArrayCollection(); | |||
$this->products = new ArrayCollection(); | |||
$this->qualityLabels = new ArrayCollection(); | |||
$this->initProducts(); | |||
} | |||
public function initProducts() | |||
{ | |||
$this->products = new ArrayCollection(); | |||
} | |||
public function __toString() |
@@ -15,6 +15,7 @@ use Lc\CaracoleBundle\Model\User\UserMerchantInterface; | |||
use Lc\CaracoleBundle\Repository\Merchant\MerchantRepository; | |||
use Lc\CaracoleBundle\Repository\Merchant\MerchantStore; | |||
use Lc\CaracoleBundle\Repository\User\UserMerchantRepository; | |||
use Lc\CaracoleBundle\Solver\Merchant\MerchantSolver; | |||
use Lc\SovBundle\Model\User\UserInterface; | |||
use Lc\SovBundle\Resolver\UrlResolver; | |||
use Lc\SovBundle\Solver\Setting\SettingSolver; | |||
@@ -37,6 +38,7 @@ class MerchantResolver | |||
protected MerchantStore $merchantStore; | |||
protected ParameterBagInterface $parameterBag; | |||
protected SettingSolver $settingSolver; | |||
protected MerchantSolver $merchantSolver; | |||
public function __construct( | |||
EntityManagerInterface $entityManager, | |||
@@ -48,7 +50,8 @@ class MerchantResolver | |||
UrlGeneratorInterface $router, | |||
MerchantStore $merchantStore, | |||
ParameterBagInterface $parameterBag, | |||
SettingSolver $settingSolver | |||
SettingSolver $settingSolver, | |||
MerchantSolver $merchantSolver | |||
) { | |||
$this->requestStack = $requestStack; | |||
$this->em = $entityManager; | |||
@@ -60,6 +63,7 @@ class MerchantResolver | |||
$this->router = $router; | |||
$this->parameterBag = $parameterBag; | |||
$this->settingSolver = $settingSolver; | |||
$this->merchantSolver = $merchantSolver; | |||
} | |||
public function isOutOfMerchant() |