Skip to content

Commit a673224

Browse files
Merge remote-tracking branch '38554/patch-18' into commpr_787643004
2 parents af53fe0 + e701e56 commit a673224

File tree

2 files changed

+27
-24
lines changed

2 files changed

+27
-24
lines changed

‎app/code/Magento/Backend/App/Area/FrontNameResolver.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,10 @@ public function getFrontName($checkHost = false)
107107
if ($checkHost && !$this->isHostBackend()) {
108108
return false;
109109
}
110-
$isCustomPathUsed = (bool)(string)$this->config->getValue(self::XML_PATH_USE_CUSTOM_ADMIN_PATH);
111-
if ($isCustomPathUsed) {
112-
return (string)$this->config->getValue(self::XML_PATH_CUSTOM_ADMIN_PATH);
113-
}
114-
return $this->defaultFrontName;
110+
111+
return $this->config->isSetFlag(self::XML_PATH_USE_CUSTOM_ADMIN_PATH)
112+
? (string)$this->config->getValue(self::XML_PATH_CUSTOM_ADMIN_PATH)
113+
: $this->defaultFrontName;
115114
}
116115

117116
/**
@@ -127,9 +126,8 @@ public function isHostBackend()
127126
if (!$this->request->getServer('HTTP_HOST')) {
128127
return false;
129128
}
130-
131-
if ($this->scopeConfig->getValue(self::XML_PATH_USE_CUSTOM_ADMIN_URL, ScopeInterface::SCOPE_STORE)) {
132-
$backendUrl = $this->scopeConfig->getValue(self::XML_PATH_CUSTOM_ADMIN_URL, ScopeInterface::SCOPE_STORE);
129+
if ($this->scopeConfig->isSetFlag(self::XML_PATH_USE_CUSTOM_ADMIN_URL)) {
130+
$backendUrl = $this->scopeConfig->getValue(self::XML_PATH_CUSTOM_ADMIN_URL);
133131
} else {
134132
$xmlPath = $this->request->isSecure() ? Store::XML_PATH_SECURE_BASE_URL : Store::XML_PATH_UNSECURE_BASE_URL;
135133
$backendUrl = $this->config->getValue($xmlPath);

‎app/code/Magento/Backend/Test/Unit/App/Area/FrontNameResolverTest.php

100644100755
Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,16 @@ protected function setUp(): void
8080
*/
8181
public function testIfCustomPathUsed(): void
8282
{
83-
$this->configMock
83+
$this->configMock->expects($this->once())
84+
->method('isSetFlag')
85+
->with(FrontNameResolver::XML_PATH_USE_CUSTOM_ADMIN_PATH)
86+
->willReturn(true);
87+
88+
$this->configMock->expects($this->once())
8489
->method('getValue')
85-
->willReturnCallback(fn($param) => match ([$param]) {
86-
['admin/url/use_custom_path'] => true,
87-
['admin/url/custom_path'] => 'expectedValue'
88-
});
90+
->with(FrontNameResolver::XML_PATH_CUSTOM_ADMIN_PATH)
91+
->willReturn('expectedValue');
92+
8993
$this->assertEquals('expectedValue', $this->model->getFrontName());
9094
}
9195

@@ -94,15 +98,11 @@ public function testIfCustomPathUsed(): void
9498
*/
9599
public function testIfCustomPathNotUsed(): void
96100
{
97-
$this->configMock->expects(
98-
$this->once()
99-
)->method(
100-
'getValue'
101-
)->with(
102-
'admin/url/use_custom_path'
103-
)->willReturn(
104-
false
105-
);
101+
$this->configMock->expects($this->once())
102+
->method('isSetFlag')
103+
->with(FrontNameResolver::XML_PATH_USE_CUSTOM_ADMIN_PATH)
104+
->willReturn(false);
105+
106106
$this->assertEquals($this->_defaultFrontName, $this->model->getFrontName());
107107
}
108108

@@ -125,7 +125,12 @@ public function testIsHostBackend(
125125
string $customAdminUrl,
126126
bool $expectedValue
127127
): void {
128-
$this->scopeConfigMock->method('getValue')
128+
$this->scopeConfigMock
129+
->method('isSetFlag')
130+
->willReturn($useCustomAdminUrl);
131+
132+
$this->scopeConfigMock
133+
->method('getValue')
129134
->willReturnMap(
130135
[
131136
[Store::XML_PATH_UNSECURE_BASE_URL, ScopeInterface::SCOPE_STORE, null, $url],
@@ -138,7 +143,7 @@ public function testIsHostBackend(
138143
],
139144
[
140145
FrontNameResolver::XML_PATH_CUSTOM_ADMIN_URL,
141-
ScopeInterface::SCOPE_STORE,
146+
ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
142147
null,
143148
$customAdminUrl
144149
]

0 commit comments

Comments
 (0)