Skip to content

Commit

Permalink
CRM_Core_Resources - Fix loading with alternate packages path
Browse files Browse the repository at this point in the history
  • Loading branch information
totten committed Jan 28, 2020
1 parent 4d5b93c commit 1143a78
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions CRM/Core/Resources.php
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,19 @@ public function coreResourceList($region) {
// Allow hooks to modify this list
CRM_Utils_Hook::coreResourceList($items, $region);

// Oof, existing listeners would expect $items to typically begin with 'bower_components/' or 'packages/'
// (using an implicit base of `[civicrm.root]`). We preserve the hook contract and cleanup $items post-hook.
$map = [
'bower_components' => rtrim(Civi::paths()->getUrl('[civicrm.bower]/.', 'absolute'), '/'),
'packages' => rtrim(Civi::paths()->getUrl('[civicrm.packages]/.', 'absolute'), '/'),
];
$filter = function($m) use ($map) {
return $map[$m[1]] . $m[2];
};
$items = array_map(function($item) use ($filter) {
return is_array($item) ? $item : preg_replace_callback(';^(bower_components|packages)(/.*);', $filter, $item);
}, $items);

return $items;
}

Expand Down

0 comments on commit 1143a78

Please sign in to comment.