11<?php
22/**
3- * Backend area front name resolver. Reads front name from configuration
4- *
53 * Copyright © Magento, Inc. All rights reserved.
64 * See COPYING.txt for license details.
75 */
6+
87namespace Magento \Backend \App \Area ;
98
9+ use Laminas \Uri \Uri ;
10+ use Magento \Backend \App \Config ;
1011use Magento \Backend \Setup \ConfigOptionsList ;
12+ use Magento \Framework \App \Area \FrontNameResolverInterface ;
1113use Magento \Framework \App \Config \ScopeConfigInterface ;
1214use Magento \Framework \App \DeploymentConfig ;
1315use Magento \Framework \App \ObjectManager ;
1416use Magento \Framework \App \RequestInterface ;
1517use Magento \Store \Model \ScopeInterface ;
1618use Magento \Store \Model \Store ;
17- use Laminas \Uri \Uri ;
1819
1920/**
20- * Class to get area front name .
21+ * Front name resolver for backend area .
2122 *
2223 * @api
2324 * @since 100.0.2
2425 */
25- class FrontNameResolver implements \ Magento \ Framework \ App \ Area \ FrontNameResolverInterface
26+ class FrontNameResolver implements FrontNameResolverInterface
2627{
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 ' ;
2829
29- const XML_PATH_CUSTOM_ADMIN_PATH = 'admin/url/custom_path ' ;
30+ public const XML_PATH_CUSTOM_ADMIN_PATH = 'admin/url/custom_path ' ;
3031
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 ' ;
3233
33- const XML_PATH_CUSTOM_ADMIN_URL = 'admin/url/custom ' ;
34+ public const XML_PATH_CUSTOM_ADMIN_URL = 'admin/url/custom ' ;
3435
3536 /**
3637 * Backend area code
3738 */
38- const AREA_CODE = 'adminhtml ' ;
39+ public const AREA_CODE = 'adminhtml ' ;
3940
4041 /**
4142 * @var array
@@ -75,14 +76,14 @@ class FrontNameResolver implements \Magento\Framework\App\Area\FrontNameResolver
7576 private $ request ;
7677
7778 /**
78- * @param \Magento\Backend\App\ Config $config
79+ * @param Config $config
7980 * @param DeploymentConfig $deploymentConfig
8081 * @param ScopeConfigInterface $scopeConfig
8182 * @param Uri $uri
8283 * @param RequestInterface $request
8384 */
8485 public function __construct (
85- \ Magento \ Backend \ App \ Config $ config ,
86+ Config $ config ,
8687 DeploymentConfig $ deploymentConfig ,
8788 ScopeConfigInterface $ scopeConfig ,
8889 Uri $ uri = null ,
@@ -131,8 +132,10 @@ public function isHostBackend()
131132 );
132133 }
133134 }
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 ;
136139 }
137140
138141 /**
@@ -149,8 +152,8 @@ private function getHostWithPort($url)
149152 $ port = $ this ->uri ->getPort ();
150153
151154 if (!$ port ) {
152- $ port = isset ( $ this ->standardPorts [$ scheme ]) ? $ this -> standardPorts [ $ scheme ] : null ;
155+ $ port = $ this ->standardPorts [$ scheme ] ?? null ;
153156 }
154- return isset ( $ port) ? $ host . ': ' . $ port : $ host ;
157+ return $ port !== null ? $ host . ': ' . $ port : $ host ;
155158 }
156159}
0 commit comments