4
4
* See COPYING.txt for license details.
5
5
*/
6
6
7
- // @codingStandardsIgnoreFile
8
-
9
7
namespace Magento \Framework ;
10
8
11
9
use Magento \Framework \App \ObjectManager ;
43
41
* - query_array: array('param1'=>'value1', 'param2'=>'value2')
44
42
* - fragment: (#)'fragment-anchor'
45
43
*
44
+ * @codingStandardsIgnoreStart
46
45
* URL structure:
47
46
*
48
47
* https://user:password@host:443/base_path/[base_script][scopeview_path]route_name/controller_name/action_name/param1/value1?query_param=query_value#fragment
49
48
* \__________A___________/\____________________________________B_____________________________________/
50
49
* \__________________C___________________/ \__________________D_________________/ \_____E_____/
51
50
* \_____________F______________/ \___________________________G______________________/
52
51
* \___________________________________________________H____________________________________________________/
52
+ * @codingStandardsIgnoreEnd
53
53
*
54
54
* - A: authority
55
55
* - B: path
@@ -145,6 +145,7 @@ class Url extends \Magento\Framework\DataObject implements \Magento\Framework\Ur
145
145
* @var \Magento\Framework\Url\RouteParamsResolverFactory
146
146
*/
147
147
private $ _routeParamsResolverFactory ;
148
+
148
149
/**
149
150
* @var \Magento\Framework\Url\ScopeResolverInterface
150
151
*/
@@ -290,7 +291,7 @@ public function setUseSession($useSession)
290
291
*/
291
292
public function getUseSession ()
292
293
{
293
- if (is_null ( $ this ->_useSession ) ) {
294
+ if ($ this ->_useSession === null ) {
294
295
$ this ->_useSession = $ this ->_sidResolver ->getUseSessionInUrl ();
295
296
}
296
297
return $ this ->_useSession ;
@@ -305,7 +306,7 @@ public function getUseSession()
305
306
*/
306
307
public function getConfigData ($ key , $ prefix = null )
307
308
{
308
- if (is_null ( $ prefix) ) {
309
+ if ($ prefix === null ) {
309
310
$ prefix = 'web/ ' . ($ this ->_isSecure () ? 'secure ' : 'unsecure ' ) . '/ ' ;
310
311
}
311
312
$ path = $ prefix . $ key ;
@@ -583,7 +584,7 @@ protected function _getRoutePath($routeParams = [])
583
584
$ routePath = $ this ->_getActionPath ();
584
585
if ($ this ->_getRouteParams ()) {
585
586
foreach ($ this ->_getRouteParams () as $ key => $ value ) {
586
- if (is_null ( $ value) || false === $ value || '' === $ value || !is_scalar ($ value )) {
587
+ if ($ value === null || false === $ value || '' === $ value || !is_scalar ($ value )) {
587
588
continue ;
588
589
}
589
590
$ routePath .= $ key . '/ ' . $ value . '/ ' ;
@@ -855,7 +856,7 @@ function ($item) use (&$isCached) {
855
856
);
856
857
}
857
858
858
- if (!$ isCached ) {
859
+ if (!$ isCached ) {
859
860
return $ this ->getUrlModifier ()->execute (
860
861
$ this ->createUrl ($ routePath , $ routeParams )
861
862
);
@@ -953,7 +954,7 @@ private function createUrl($routePath = null, array $routeParams = null)
953
954
$ this ->_queryParamsResolver ->unsetData ('query_params ' );
954
955
}
955
956
956
- if (! is_null ( $ fragment) ) {
957
+ if ($ fragment !== null ) {
957
958
$ url .= '# ' . $ this ->getEscaper ()->encodeUrlParam ($ fragment );
958
959
}
959
960
$ this ->getRouteParamsResolver ()->unsetData ('secure ' );
@@ -1065,7 +1066,7 @@ public function sessionUrlVar($html)
1065
1066
function ($ match ) {
1066
1067
if ($ this ->useSessionIdForUrl ($ match [2 ] == 'S ' ? true : false )) {
1067
1068
return $ match [1 ] . $ this ->_sidResolver ->getSessionIdQueryParam ($ this ->_session ) . '= '
1068
- . $ this ->_session ->getSessionId () . (isset ($ match [3 ]) ? $ match [3 ] : '' );
1069
+ . $ this ->_session ->getSessionId () . (isset ($ match [3 ]) ? $ match [3 ] : '' );
1069
1070
} else {
1070
1071
if ($ match [1 ] == '? ' ) {
1071
1072
return isset ($ match [3 ]) ? '? ' : '' ;
@@ -1087,9 +1088,12 @@ function ($match) {
1087
1088
public function useSessionIdForUrl ($ secure = false )
1088
1089
{
1089
1090
$ key = 'use_session_id_for_url_ ' . (int )$ secure ;
1090
- if (is_null ( $ this ->getData ($ key )) ) {
1091
+ if ($ this ->getData ($ key ) === null ) {
1091
1092
$ httpHost = $ this ->_request ->getHttpHost ();
1092
- $ urlHost = parse_url ($ this ->_getScope ()->getBaseUrl (UrlInterface::URL_TYPE_LINK , $ secure ), PHP_URL_HOST );
1093
+ $ urlHost = parse_url (
1094
+ $ this ->_getScope ()->getBaseUrl (UrlInterface::URL_TYPE_LINK , $ secure ),
1095
+ PHP_URL_HOST
1096
+ );
1093
1097
1094
1098
if ($ httpHost != $ urlHost ) {
1095
1099
$ this ->setData ($ key , true );
@@ -1192,7 +1196,7 @@ private function getEscaper()
1192
1196
{
1193
1197
if ($ this ->escaper == null ) {
1194
1198
$ this ->escaper = \Magento \Framework \App \ObjectManager::getInstance ()
1195
- ->get (\Magento \Framework \Escaper::class);
1199
+ ->get (\Magento \Framework \Escaper::class);
1196
1200
}
1197
1201
return $ this ->escaper ;
1198
1202
}
0 commit comments