8 use \Magento\Store\Model\Store;
9 use \Magento\Store\Api\Data\StoreInterface;
10 use \Magento\Store\Model\ScopeInterface as StoreScopeInterface;
59 public function beforeSetRouteParams(
62 $unsetOldParams =
true 64 if (isset(
$data[
'_scope'])) {
65 $subject->setScope(
$data[
'_scope']);
66 unset(
$data[
'_scope']);
68 if (isset(
$data[
'_scope_to_url']) && (
bool)
$data[
'_scope_to_url'] ===
true) {
70 $currentScope = $subject->getScope();
71 $storeCode = $currentScope && $currentScope instanceof StoreInterface ?
72 $currentScope->getCode() :
73 $this->storeManager->getStore()->getCode();
75 $useStoreInUrl = $this->scopeConfig->getValue(
77 StoreScopeInterface::SCOPE_STORE,
81 if ($useStoreInUrl && !$this->storeManager->hasSingleStore()) {
82 $this->queryParamsResolver->setQueryParam(
'___store',
$storeCode);
85 unset(
$data[
'_scope_to_url']);
87 return [
$data, $unsetOldParams];
const XML_PATH_STORE_IN_URL
__construct(\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Url\QueryParamsResolverInterface $queryParamsResolver)