mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-03 18:12:40 +00:00
Added Plugin.asset support for HtmlHelper css(), script(), and image() with tests
This commit is contained in:
parent
b6f99bc0b9
commit
7fe6a4d5ea
5 changed files with 238 additions and 24 deletions
|
@ -267,15 +267,30 @@ class Helper extends Object {
|
|||
* @param array $options Options array. Possible keys:
|
||||
* `fullBase` Return full url with domain name
|
||||
* `pathPrefix` Path prefix for relative urls
|
||||
* `ext` Asset extension to append
|
||||
* `plugin` False value will prevent parsing path as a plugin
|
||||
* @return string Generated url
|
||||
*/
|
||||
public function assetUrl($path, array $options) {
|
||||
if (is_array($path)) {
|
||||
$path = $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 = $this->assetTimestamp($this->webroot($path));
|
||||
|
||||
if (!empty($options['fullBase'])) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue