dev/core#2117 - scriptFile, styleFile - Automatically register URL aliases
authorTim Otten <totten@civicrm.org>
Wed, 14 Oct 2020 00:29:29 +0000 (17:29 -0700)
committerTim Otten <totten@civicrm.org>
Wed, 14 Oct 2020 01:56:35 +0000 (18:56 -0700)
This allows backward compatibility for customizations which targetted these
resources by their URL.

CRM/Core/Resources/CollectionTrait.php

index 38abdea67979d8a11f1c54f990b0290a4348833b..71fe17ece0ccfb8c93df4ab5950e843e27e743ac 100644 (file)
@@ -114,6 +114,9 @@ trait CRM_Core_Resources_CollectionTrait {
       }
       $snippet['scriptFileUrls'] = [$res->getUrl($ext, $res->filterMinify($ext, $file), TRUE)];
     }
+    if ($snippet['type'] === 'scriptFile' && !isset($snippet['aliases'])) {
+      $snippet['aliases'] = $snippet['scriptFileUrls'];
+    }
 
     if ($snippet['type'] === 'styleFile' && !isset($snippet['styleFileUrls'])) {
       /** @var Civi\Core\Themes $theme */
@@ -121,6 +124,9 @@ trait CRM_Core_Resources_CollectionTrait {
       list ($ext, $file) = $snippet['styleFile'];
       $snippet['styleFileUrls'] = $theme->resolveUrls($theme->getActiveThemeKey(), $ext, $file);
     }
+    if ($snippet['type'] === 'styleFile' && !isset($snippet['aliases'])) {
+      $snippet['aliases'] = $snippet['styleFileUrls'];
+    }
 
     if (isset($snippet['aliases']) && !is_array($snippet['aliases'])) {
       $snippet['aliases'] = [$snippet['aliases']];