Browse Source

MerchantResolver

packProduct
Guillaume 3 years ago
parent
commit
b568200366
1 changed files with 6 additions and 2 deletions
  1. +6
    -2
      Resolver/MerchantResolver.php

+ 6
- 2
Resolver/MerchantResolver.php View File

use Lc\CaracoleBundle\Repository\User\UserMerchantRepository; use Lc\CaracoleBundle\Repository\User\UserMerchantRepository;
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 Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
protected UrlGeneratorInterface $router; protected UrlGeneratorInterface $router;
protected MerchantStore $merchantStore; protected MerchantStore $merchantStore;
protected ParameterBagInterface $parameterBag; protected ParameterBagInterface $parameterBag;
protected SettingSolver $settingSolver;


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


public function getCurrent(): MerchantInterface public function getCurrent(): MerchantInterface
} // distant } // distant
else { else {
foreach ($merchants as $merchant) { foreach ($merchants as $merchant) {
$url = $merchant->getSettingValue(MerchantSettingDefinition::SETTING_URL);
$url = $this->settingSolver->getSettingValue($merchant, MerchantSettingDefinition::SETTING_URL);
if ($url && strlen($url) && strpos($url, $_SERVER['HTTP_HOST']) !== false) { if ($url && strlen($url) && strpos($url, $_SERVER['HTTP_HOST']) !== false) {
$this->currentMerchant = $merchant; $this->currentMerchant = $merchant;
} }

Loading…
Cancel
Save