Created
January 21, 2015 14:38
-
-
Save lorenzo/5227bf5dc4a1137bc19d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function assetUrl($path, $options = array()) { | |
if (is_array($path)) { | |
return $this->url($path, !empty($options['fullBase'])); | |
} | |
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 = $this->_encodeUrl($this->assetTimestamp($this->webroot($path))); | |
$path = rtrim(Configure::read('App.assetsUrl'), '/') . '/' . ltrim($path, '/'); | |
$path = http_build_url($path, ['query' => 'v=' . Configure::read('App.current_version')], HTTP_URL_JOIN_QUERY); | |
return $path; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment