Skip to content

Commit 03a2f6c

Browse files
author
Dale Sikkema
committed
MAGETWO-43691: Custom admin path does not work correctly
- get base url from config, not Url framework
1 parent f4cc820 commit 03a2f6c

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
namespace Magento\Backend\App\Area;
99

1010
use Magento\Backend\Setup\ConfigOptionsList;
11+
use Magento\Framework\App\Config\ScopeConfigInterface;
1112
use Magento\Framework\App\DeploymentConfig;
13+
use Magento\Store\Model\ScopeInterface;
14+
use Magento\Store\Model\Store;
1215

1316
class FrontNameResolver implements \Magento\Framework\App\Area\FrontNameResolverInterface
1417
{
@@ -38,24 +41,22 @@ class FrontNameResolver implements \Magento\Framework\App\Area\FrontNameResolver
3841
*/
3942
protected $deploymentConfig;
4043

41-
/**
42-
* @var \Magento\Backend\Model\UrlInterface
43-
*/
44-
protected $backendUrl;
44+
/** @var ScopeConfigInterface */
45+
private $configInterface;
4546

4647
/**
4748
* @param \Magento\Backend\App\Config $config
4849
* @param DeploymentConfig $deploymentConfig
49-
* @param \Magento\Backend\Model\UrlInterface $backendUrl
50+
* @param ScopeConfigInterface $configInterface
5051
*/
5152
public function __construct(
5253
\Magento\Backend\App\Config $config,
5354
DeploymentConfig $deploymentConfig,
54-
\Magento\Backend\Model\UrlInterface $backendUrl
55+
ScopeConfigInterface $configInterface
5556
) {
5657
$this->config = $config;
5758
$this->defaultFrontName = $deploymentConfig->get(ConfigOptionsList::CONFIG_PATH_BACKEND_FRONTNAME);
58-
$this->backendUrl = $backendUrl;
59+
$this->configInterface = $configInterface;
5960
}
6061

6162
/**
@@ -82,7 +83,8 @@ public function getFrontName($checkHost = false)
8283
*/
8384
public function isHostBackend()
8485
{
85-
$backendHost = parse_url(trim($this->backendUrl->getBaseUrl()), PHP_URL_HOST);
86+
$backendUrl = $this->configInterface->getValue(Store::XML_PATH_UNSECURE_BASE_URL, ScopeInterface::SCOPE_STORE);
87+
$backendHost = parse_url(trim($backendUrl), PHP_URL_HOST);
8688
$host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
8789
return (strcasecmp($backendHost, $host) === 0);
8890
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ protected function setUp()
3333
->with(ConfigOptionsList::CONFIG_PATH_BACKEND_FRONTNAME)
3434
->will($this->returnValue($this->_defaultFrontName));
3535
$this->_configMock = $this->getMock('\Magento\Backend\App\Config', [], [], '', false);
36-
$backendUrlMock = $this->getMock('\Magento\Backend\Model\UrlInterface', [], [], '', false);
37-
$this->_model = new FrontNameResolver($this->_configMock, $deploymentConfigMock, $backendUrlMock);
36+
$configMock = $this->getMock('\Magento\Framework\App\Config\ScopeConfigInterface', [], [], '', false);
37+
$this->_model = new FrontNameResolver($this->_configMock, $deploymentConfigMock, $configMock);
3838
}
3939

4040
public function testIfCustomPathUsed()

0 commit comments

Comments
 (0)