mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Remove nested conditionals.
This commit is contained in:
parent
9c0939b888
commit
7402eea9eb
1 changed files with 29 additions and 28 deletions
|
@ -292,36 +292,37 @@ class Helper extends Object {
|
||||||
*/
|
*/
|
||||||
public function assetUrl($path, $options = array()) {
|
public function assetUrl($path, $options = array()) {
|
||||||
if (is_array($path)) {
|
if (is_array($path)) {
|
||||||
$path = $this->url($path, !empty($options['fullBase']));
|
return $this->url($path, !empty($options['fullBase']));
|
||||||
} elseif (strpos($path, '://') === false) {
|
|
||||||
if (!array_key_exists('plugin', $options) || $options['plugin'] !== false) {
|
|
||||||
list($plugin, $path) = $this->_View->pluginSplit($path, false);
|
|
||||||
}
|
|
||||||
if (!empty($options['pathPrefix']) && $path[0] !== '/') {
|
|
||||||
$path = $options['pathPrefix'] . $path;
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
!empty($options['ext']) &&
|
|
||||||
strpos($path, '?') === false &&
|
|
||||||
substr($path, -strlen($options['ext'])) !== $options['ext']
|
|
||||||
) {
|
|
||||||
$path .= $options['ext'];
|
|
||||||
}
|
|
||||||
if (isset($plugin)) {
|
|
||||||
$path = Inflector::underscore($plugin) . '/' . $path;
|
|
||||||
}
|
|
||||||
$path = h($this->assetTimestamp($this->webroot($path)));
|
|
||||||
|
|
||||||
if (!empty($options['fullBase'])) {
|
|
||||||
$base = $this->url('/', true);
|
|
||||||
$len = strlen($this->request->webroot);
|
|
||||||
if ($len) {
|
|
||||||
$base = substr($base, 0, -$len);
|
|
||||||
}
|
|
||||||
$path = $base . $path;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (strpos($path, '://') !== false) {
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
|
if (!array_key_exists('plugin', $options) || $options['plugin'] !== false) {
|
||||||
|
list($plugin, $path) = $this->_View->pluginSplit($path, false);
|
||||||
|
}
|
||||||
|
if (!empty($options['pathPrefix']) && $path[0] !== '/') {
|
||||||
|
$path = $options['pathPrefix'] . $path;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
!empty($options['ext']) &&
|
||||||
|
strpos($path, '?') === false &&
|
||||||
|
substr($path, -strlen($options['ext'])) !== $options['ext']
|
||||||
|
) {
|
||||||
|
$path .= $options['ext'];
|
||||||
|
}
|
||||||
|
if (isset($plugin)) {
|
||||||
|
$path = Inflector::underscore($plugin) . '/' . $path;
|
||||||
|
}
|
||||||
|
$path = h($this->assetTimestamp($this->webroot($path)));
|
||||||
|
|
||||||
|
if (!empty($options['fullBase'])) {
|
||||||
|
$base = $this->url('/', true);
|
||||||
|
$len = strlen($this->request->webroot);
|
||||||
|
if ($len) {
|
||||||
|
$base = substr($base, 0, -$len);
|
||||||
|
}
|
||||||
|
$path = $base . $path;
|
||||||
|
}
|
||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue