|
|
@@ -19,13 +19,20 @@ class SectionResolver |
|
|
|
protected MerchantResolver $merchantResolver; |
|
|
|
protected SectionStore $sectionStore; |
|
|
|
protected RequestStack $requestStack; |
|
|
|
protected UrlResolver $urlResolver; |
|
|
|
|
|
|
|
public function __construct(EntityManagerInterface $entityManager, MerchantResolver $merchantResolver, SectionStore $sectionStore, RequestStack $requestStack) |
|
|
|
{ |
|
|
|
public function __construct( |
|
|
|
EntityManagerInterface $entityManager, |
|
|
|
MerchantResolver $merchantResolver, |
|
|
|
SectionStore $sectionStore, |
|
|
|
RequestStack $requestStack, |
|
|
|
UrlResolver $urlResolver |
|
|
|
) { |
|
|
|
$this->entityManager = $entityManager; |
|
|
|
$this->merchantResolver = $merchantResolver; |
|
|
|
$this->sectionStore = $sectionStore; |
|
|
|
$this->requestStack = $requestStack; |
|
|
|
$this->urlResolver = $urlResolver; |
|
|
|
} |
|
|
|
|
|
|
|
public function getCurrent() |
|
|
@@ -33,7 +40,7 @@ class SectionResolver |
|
|
|
$requestAttributesArray = $this->requestStack->getMainRequest()->attributes->all(); |
|
|
|
|
|
|
|
// admin |
|
|
|
if(isset($requestAttributesArray['easyadmin_context'])) { |
|
|
|
if (isset($requestAttributesArray['easyadmin_context'])) { |
|
|
|
$currentAdminSection = null; |
|
|
|
$userMerchant = $this->merchantResolver->getUserMerchant(); |
|
|
|
|
|
|
@@ -52,12 +59,31 @@ class SectionResolver |
|
|
|
} |
|
|
|
|
|
|
|
return $currentAdminSection; |
|
|
|
} |
|
|
|
// front |
|
|
|
} // front |
|
|
|
else { |
|
|
|
return $this->sectionStore |
|
|
|
->setMerchant($this->merchantResolver->getCurrent()) |
|
|
|
->getOneDefault(); |
|
|
|
$sectionCurrent = null; |
|
|
|
$isCli = php_sapi_name() === 'cli'; |
|
|
|
|
|
|
|
// local |
|
|
|
if ($isCli || $this->urlResolver->isServerLocalhost()) { |
|
|
|
$sectionArray = $this->sectionStore |
|
|
|
->setMerchant($this->merchantResolver->getCurrent()) |
|
|
|
->getOnline(); |
|
|
|
|
|
|
|
foreach ($sectionArray as $section) { |
|
|
|
if ($section->getDevAlias() == $_ENV['CURRENT_SECTION_LOCAL']) { |
|
|
|
$sectionCurrent = $section; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// distant |
|
|
|
else { |
|
|
|
$sectionCurrent = $this->sectionStore |
|
|
|
->setMerchant($this->merchantResolver->getCurrent()) |
|
|
|
->getOneDefault(); |
|
|
|
} |
|
|
|
|
|
|
|
return $sectionCurrent; |
|
|
|
} |
|
|
|
} |
|
|
|
|