From 1143a7815b1abbcb7cfc0cab6c754e499d11d064 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Wed, 15 Jan 2020 14:37:27 -0800 Subject: [PATCH] CRM_Core_Resources - Fix loading with alternate packages path --- CRM/Core/Resources.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CRM/Core/Resources.php b/CRM/Core/Resources.php index 2c4f211c431..99448dd0da1 100644 --- a/CRM/Core/Resources.php +++ b/CRM/Core/Resources.php @@ -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; }