-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update code to reduce redundancy and simplify readability #28608
Changes from 4 commits
01309d8
45a668a
0a1b76a
910da38
9009851
9b954c0
eaba8c2
7e7b645
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -199,13 +199,8 @@ public function isDirectAccessFrontendName($code) | |
*/ | ||
public function getBasePath() | ||
{ | ||
$path = parent::getBasePath(); | ||
if (empty($path)) { | ||
$path = '/'; | ||
} else { | ||
$path = str_replace('\\', '/', $path); | ||
} | ||
return $path; | ||
return empty(parent::getBasePath()) ? '/' | ||
: str_replace('\\', '/', parent::getBasePath()); | ||
} | ||
|
||
/** | ||
|
@@ -298,10 +293,9 @@ public function getBeforeForwardInfo($name = null) | |
{ | ||
if ($name === null) { | ||
return $this->beforeForwardInfo; | ||
} elseif (isset($this->beforeForwardInfo[$name])) { | ||
return $this->beforeForwardInfo[$name]; | ||
} | ||
return null; | ||
|
||
return $this->beforeForwardInfo[$name] ?? null; | ||
} | ||
|
||
/** | ||
|
@@ -311,13 +305,9 @@ public function getBeforeForwardInfo($name = null) | |
*/ | ||
public function isAjax() | ||
{ | ||
if ($this->isXmlHttpRequest()) { | ||
return true; | ||
} | ||
if ($this->getParam('ajax') || $this->getParam('isAjax')) { | ||
return true; | ||
} | ||
return false; | ||
return $this->isXmlHttpRequest() | ||
|| $this->getParam('ajax', null) | ||
|| $this->getParam('isAjax', null); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default value is
|
||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. $this->getParam('ajax', null), second parameter is not required |
||
|
||
/** | ||
|
@@ -365,7 +355,7 @@ public static function getDistroBaseUrlPath($server) | |
$result = ''; | ||
if (isset($server['SCRIPT_NAME'])) { | ||
$envPath = str_replace('\\', '/', dirname(str_replace('\\', '/', $server['SCRIPT_NAME']))); | ||
if ($envPath != '.' && $envPath != '/') { | ||
if ($envPath !== '.' && $envPath !== '/') { | ||
$result = $envPath; | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If 'parent: getBasePath()' is not empty, we will call 'parent::getBasePath()' again.
I think it is better to use the $ path variable.