3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
13 * Define some common, global lists of resources.
15 class CRM_Core_Resources_Common
{
17 const REGION
= 'html-header';
20 * The 'bundle.coreStyles' service is a collection of resources used on some
21 * non-Civi pages (wherein Civi may be mixed-in).
25 * @return \CRM_Core_Resources_Bundle
27 public static function createStyleBundle($name) {
28 $bundle = new CRM_Core_Resources_Bundle($name);
30 // Load custom or core css
31 $config = CRM_Core_Config
::singleton();
32 if (!empty($config->customCSSURL
)) {
33 $customCSSURL = Civi
::resources()->addCacheCode($config->customCSSURL
);
34 $bundle->addStyleUrl($customCSSURL, 99);
36 if (!Civi
::settings()->get('disable_core_css')) {
37 $bundle->addStyleFile('civicrm', 'css/civicrm.css', -99);
39 // crm-i.css added ahead of other styles so it can be overridden by FA.
40 $bundle->addStyleFile('civicrm', 'css/crm-i.css', -101);
42 CRM_Utils_Hook
::alterBundle($bundle);
43 self
::useRegion($bundle, self
::REGION
);
48 * The 'bundle.coreResources' service is a collection of resources
49 * shared by Civi pages (ie pages where Civi controls rendering).
52 * i.e. 'coreResources'
53 * @return \CRM_Core_Resources_Bundle
55 public static function createFullBundle($name) {
56 $bundle = new CRM_Core_Resources_Bundle($name);
58 CRM_Utils_Hook
::alterBundle($bundle);
59 self
::useRegion($bundle, self
::REGION
);
64 * Ensure that all elements of the bundle are in the same region.
66 * @param CRM_Core_Resources_Bundle $bundle
67 * @param string $region
68 * @return CRM_Core_Resources_Bundle
70 protected static function useRegion($bundle, $region) {
71 $bundle->filter(function ($s) use ($region) {
72 if ($s['type'] !== 'settings' && !isset($s['region'])) {
73 $s['region'] = $region;