Browse Source

Merge branch 'develop'

master
Guillaume 1 year ago
parent
commit
ed59b31385
3 changed files with 18 additions and 6 deletions
  1. +7
    -4
      Builder/User/UserMerchantBuilder.php
  2. +6
    -1
      Model/Product/ProductFamilyModel.php
  3. +5
    -1
      Resolver/MerchantResolver.php

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

$this->userMerchantStore = $userMerchantStore; $this->userMerchantStore = $userMerchantStore;
} }


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

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


return $userMerchant; return $userMerchant;

+ 6
- 1
Model/Product/ProductFamilyModel.php View File

public function __construct() public function __construct()
{ {
$this->productCategories = new ArrayCollection(); $this->productCategories = new ArrayCollection();
$this->products = new ArrayCollection();
$this->qualityLabels = new ArrayCollection(); $this->qualityLabels = new ArrayCollection();
$this->initProducts();
}

public function initProducts()
{
$this->products = new ArrayCollection();
} }


public function __toString() public function __toString()

+ 5
- 1
Resolver/MerchantResolver.php View File

use Lc\CaracoleBundle\Repository\Merchant\MerchantRepository; use Lc\CaracoleBundle\Repository\Merchant\MerchantRepository;
use Lc\CaracoleBundle\Repository\Merchant\MerchantStore; use Lc\CaracoleBundle\Repository\Merchant\MerchantStore;
use Lc\CaracoleBundle\Repository\User\UserMerchantRepository; use Lc\CaracoleBundle\Repository\User\UserMerchantRepository;
use Lc\CaracoleBundle\Solver\Merchant\MerchantSolver;
use Lc\SovBundle\Model\User\UserInterface; use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Resolver\UrlResolver; use Lc\SovBundle\Resolver\UrlResolver;
use Lc\SovBundle\Solver\Setting\SettingSolver; use Lc\SovBundle\Solver\Setting\SettingSolver;
protected MerchantStore $merchantStore; protected MerchantStore $merchantStore;
protected ParameterBagInterface $parameterBag; protected ParameterBagInterface $parameterBag;
protected SettingSolver $settingSolver; protected SettingSolver $settingSolver;
protected MerchantSolver $merchantSolver;


public function __construct( public function __construct(
EntityManagerInterface $entityManager, EntityManagerInterface $entityManager,
UrlGeneratorInterface $router, UrlGeneratorInterface $router,
MerchantStore $merchantStore, MerchantStore $merchantStore,
ParameterBagInterface $parameterBag, ParameterBagInterface $parameterBag,
SettingSolver $settingSolver
SettingSolver $settingSolver,
MerchantSolver $merchantSolver
) { ) {
$this->requestStack = $requestStack; $this->requestStack = $requestStack;
$this->em = $entityManager; $this->em = $entityManager;
$this->router = $router; $this->router = $router;
$this->parameterBag = $parameterBag; $this->parameterBag = $parameterBag;
$this->settingSolver = $settingSolver; $this->settingSolver = $settingSolver;
$this->merchantSolver = $merchantSolver;
} }


public function isOutOfMerchant() public function isOutOfMerchant()

Loading…
Cancel
Save