![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/cartforge.co/vendor/magento/module-store/Url/Plugin/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Store\Url\Plugin; use \Magento\Store\Model\Store; use \Magento\Store\Api\Data\StoreInterface; use \Magento\Store\Model\ScopeInterface as StoreScopeInterface; /** * Plugin for \Magento\Framework\Url\RouteParamsResolver */ class RouteParamsResolver { /** * @var \Magento\Framework\App\Config\ScopeConfigInterface */ protected $scopeConfig; /** * @var \Magento\Store\Model\StoreManagerInterface */ protected $storeManager; /** * @var \Magento\Framework\Url\QueryParamsResolverInterface */ protected $queryParamsResolver; /** * Initialize dependencies. * * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Framework\Url\QueryParamsResolverInterface $queryParamsResolver */ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Url\QueryParamsResolverInterface $queryParamsResolver ) { $this->scopeConfig = $scopeConfig; $this->storeManager = $storeManager; $this->queryParamsResolver = $queryParamsResolver; } /** * Process scope query parameters. * * @param \Magento\Framework\Url\RouteParamsResolver $subject * @param array $data * @param bool $unsetOldParams * @throws \Magento\Framework\Exception\NoSuchEntityException * * @return array */ public function beforeSetRouteParams( \Magento\Framework\Url\RouteParamsResolver $subject, array $data, $unsetOldParams = true ) { if (isset($data['_scope'])) { $subject->setScope($data['_scope']); unset($data['_scope']); } if (isset($data['_scope_to_url']) && (bool)$data['_scope_to_url'] === true) { /** @var StoreInterface $currentScope */ $currentScope = $subject->getScope(); $storeCode = $currentScope && $currentScope instanceof StoreInterface ? $currentScope->getCode() : $this->storeManager->getStore()->getCode(); $useStoreInUrl = $this->scopeConfig->getValue( Store::XML_PATH_STORE_IN_URL, StoreScopeInterface::SCOPE_STORE, $storeCode ); if (!$useStoreInUrl && !$this->storeManager->hasSingleStore()) { $this->queryParamsResolver->setQueryParam('___store', $storeCode); } } unset($data['_scope_to_url']); return [$data, $unsetOldParams]; } }