Skip to content

Commit

Permalink
Optimized calculation of path of assets
Browse files Browse the repository at this point in the history
  • Loading branch information
jbogdani committed Aug 28, 2021
1 parent ba70072 commit b3e6e26
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
28 changes: 15 additions & 13 deletions lib/Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,20 +138,22 @@ public static function resolve($name, $type = false, $source = false, $version =
$type = 'css';
}

if ($type === 'js' && file_exists('sites/default/js/' . $name)) {

$path = $basePath . 'sites/default/js/' . $name;

} else if ($type === 'css' && file_exists('sites/default/css/' . $name)){

$path = $basePath . 'sites/default/css/' . $name;

} else {

$path = $name;

$path = $name;

// If type is js or css, look for file in local filestsyem, with and without basePath.
if ($type === 'js' || $type === 'css') {
foreach ([
"{$basePath}sites/default/{$type}/{$name}",
"sites/default/{$type}/{$name}",
"{$basePath}{$type}/{$name}",
"{$type}/{$name}",
"{$name}",
] as $p) {
if (file_exists($p)){
$path = $basePath . $p;
}
}
}

}

return [
Expand Down
1 change: 1 addition & 0 deletions version
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
5.6.2[] = "Optimized calculation of path of assets"
5.6.1[] = "Updated Twig to v. 3.3.2"
5.5.13[] = "Fixed bug with link to controller in protected tags public forms"
5.5.12[] = "Fixed issue with serach string not being url_decoded"
Expand Down

0 comments on commit b3e6e26

Please sign in to comment.