1
1
<?php
2
2
/**
3
- * Backend area front name resolver. Reads front name from configuration
4
- *
5
3
* Copyright © Magento, Inc. All rights reserved.
6
4
* See COPYING.txt for license details.
7
5
*/
6
+
8
7
namespace Magento \Backend \App \Area ;
9
8
9
+ use Laminas \Uri \Uri ;
10
+ use Magento \Backend \App \Config ;
10
11
use Magento \Backend \Setup \ConfigOptionsList ;
12
+ use Magento \Framework \App \Area \FrontNameResolverInterface ;
11
13
use Magento \Framework \App \Config \ScopeConfigInterface ;
12
14
use Magento \Framework \App \DeploymentConfig ;
13
15
use Magento \Framework \App \ObjectManager ;
14
16
use Magento \Framework \App \RequestInterface ;
15
17
use Magento \Store \Model \ScopeInterface ;
16
18
use Magento \Store \Model \Store ;
17
- use Laminas \Uri \Uri ;
18
19
19
20
/**
20
- * Class to get area front name .
21
+ * Front name resolver for backend area .
21
22
*
22
23
* @api
23
24
* @since 100.0.2
24
25
*/
25
- class FrontNameResolver implements \ Magento \ Framework \ App \ Area \ FrontNameResolverInterface
26
+ class FrontNameResolver implements FrontNameResolverInterface
26
27
{
27
- const XML_PATH_USE_CUSTOM_ADMIN_PATH = 'admin/url/use_custom_path ' ;
28
+ public const XML_PATH_USE_CUSTOM_ADMIN_PATH = 'admin/url/use_custom_path ' ;
28
29
29
- const XML_PATH_CUSTOM_ADMIN_PATH = 'admin/url/custom_path ' ;
30
+ public const XML_PATH_CUSTOM_ADMIN_PATH = 'admin/url/custom_path ' ;
30
31
31
- const XML_PATH_USE_CUSTOM_ADMIN_URL = 'admin/url/use_custom ' ;
32
+ public const XML_PATH_USE_CUSTOM_ADMIN_URL = 'admin/url/use_custom ' ;
32
33
33
- const XML_PATH_CUSTOM_ADMIN_URL = 'admin/url/custom ' ;
34
+ public const XML_PATH_CUSTOM_ADMIN_URL = 'admin/url/custom ' ;
34
35
35
36
/**
36
37
* Backend area code
37
38
*/
38
- const AREA_CODE = 'adminhtml ' ;
39
+ public const AREA_CODE = 'adminhtml ' ;
39
40
40
41
/**
41
42
* @var array
@@ -75,14 +76,14 @@ class FrontNameResolver implements \Magento\Framework\App\Area\FrontNameResolver
75
76
private $ request ;
76
77
77
78
/**
78
- * @param \Magento\Backend\App\ Config $config
79
+ * @param Config $config
79
80
* @param DeploymentConfig $deploymentConfig
80
81
* @param ScopeConfigInterface $scopeConfig
81
82
* @param Uri $uri
82
83
* @param RequestInterface $request
83
84
*/
84
85
public function __construct (
85
- \ Magento \ Backend \ App \ Config $ config ,
86
+ Config $ config ,
86
87
DeploymentConfig $ deploymentConfig ,
87
88
ScopeConfigInterface $ scopeConfig ,
88
89
Uri $ uri = null ,
@@ -131,8 +132,10 @@ public function isHostBackend()
131
132
);
132
133
}
133
134
}
134
- $ host = $ this ->request ->getServer ('HTTP_HOST ' , '' );
135
- return stripos ($ this ->getHostWithPort ($ backendUrl ), (string ) $ host ) !== false ;
135
+ $ host = (string ) $ this ->request ->getServer ('HTTP_HOST ' , '' );
136
+ $ hostWithPort = $ this ->getHostWithPort ($ backendUrl );
137
+
138
+ return !($ hostWithPort === null || $ host === '' ) && stripos ($ hostWithPort , $ host ) !== false ;
136
139
}
137
140
138
141
/**
@@ -149,8 +152,8 @@ private function getHostWithPort($url)
149
152
$ port = $ this ->uri ->getPort ();
150
153
151
154
if (!$ port ) {
152
- $ port = isset ( $ this ->standardPorts [$ scheme ]) ? $ this -> standardPorts [ $ scheme ] : null ;
155
+ $ port = $ this ->standardPorts [$ scheme ] ?? null ;
153
156
}
154
- return isset ( $ port) ? $ host . ': ' . $ port : $ host ;
157
+ return $ port !== null ? $ host . ': ' . $ port : $ host ;
155
158
}
156
159
}
0 commit comments