File tree Expand file tree Collapse file tree 4 files changed +15
-2
lines changed Expand file tree Collapse file tree 4 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ class Config
20
20
private const CONFIG_PATH_STORE_PATH_URL = 'web/url/store_path_url ' ;
21
21
private const CONFIG_PATH_CUSTOM_PATH_MAPPER = 'web/url/custom_path_mapper ' ;
22
22
private const CONFIG_PATH_UNSET_SINGLE_STORE_PATH = 'web/url/unset_single_store_path ' ;
23
+ private const CONFIG_PATH_BASE_URL_RESOLVER = 'web/url/base_url_resolver ' ;
23
24
24
25
private ?array $ customPathMapper = null ;
25
26
@@ -34,6 +35,11 @@ public function isEnabled(): bool
34
35
&& ($ this ->getStorePathType () !== PathType::StoreCode || $ this ->isUnsetSingleStorePath ());
35
36
}
36
37
38
+ public function isBaseUrlResolverEnabled (): bool
39
+ {
40
+ return $ this ->scopeConfig ->isSetFlag (self ::CONFIG_PATH_BASE_URL_RESOLVER );
41
+ }
42
+
37
43
public function getStorePathType (): PathType
38
44
{
39
45
return PathType::from ($ this ->scopeConfig ->getValue (self ::CONFIG_PATH_STORE_PATH_URL ));
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ public function __construct(
29
29
30
30
public function beforeGetValidStoreCode (Subject $ subject , Http $ request , string $ pathInfo = '' ): array
31
31
{
32
- if ($ this ->config ->isEnabled ()) {
32
+ if ($ this ->config ->isBaseUrlResolverEnabled ()) {
33
33
$ uri = strtok ($ request ->getUriString (), '? ' ) . '/ ' ;
34
34
if ($ uri !== false ) {
35
35
if ($ pathInfo === '' ) {
@@ -50,7 +50,7 @@ private function resolveByLinkUrl(string $uri): string
50
50
/** @var Store $store */
51
51
foreach ($ this ->storeRepository ->getList () as $ store ) {
52
52
if ($ store ->getId () && str_starts_with ($ uri , $ store ->getBaseUrl ())) {
53
- $ pathInfo = $ store ->getCode ();
53
+ return $ store ->getCode ();
54
54
}
55
55
}
56
56
Original file line number Diff line number Diff line change 43
43
</depends >
44
44
<comment >When enabled, websites with a single store won't use the Store Path in URLs.</comment >
45
45
</field >
46
+ <field id =" base_url_resolver" type =" select" translate =" label comment" showInDefault =" 1" showInWebsite =" 0" showInStore =" 0" sortOrder =" 15" canRestore =" 1" >
47
+ <label >Use Base Url Resolver</label >
48
+ <source_model >Magento\Config\Model\Config\Source\Yesno</source_model >
49
+ <config_path >web/url/base_url_resolver</config_path >
50
+ <comment >When enabled, scope is resolved from the base url match.</comment >
51
+ </field >
46
52
</group >
47
53
</section >
48
54
</system >
Original file line number Diff line number Diff line change 11
11
<url >
12
12
<store_path_url >store_code</store_path_url >
13
13
<unset_single_store_path >1</unset_single_store_path >
14
+ <base_url_resolver >1</base_url_resolver >
14
15
</url >
15
16
</web >
16
17
</default >
You can’t perform that action at this time.
0 commit comments