+ /**
+ * Create a "basic" (generic) bundle.
+ *
+ * The bundle goes through some lifecycle events (like `hook_alterBundle`).
+ *
+ * To define default content for a basic bundle, you may either give an
+ * `$init` function or subscribe to `hook_alterBundle`.
+ *
+ * @param string $name
+ * Symbolic name of the bundle.
+ * @param callable|NULL $init
+ * Optional initialization function. Populate default resources.
+ * Signature: `function($bundle): void`
+ * Example: `function myinit($b) { $b->addScriptFile(...)->addStyleFile(...); }`
+ * @param string|string[] $types
+ * List of resource-types to permit in this bundle. NULL for a default list.
+ * Example: ['styleFile', 'styleUrl']
+ * The following aliases are allowed: '*all*', '*default*', '*script*', '*style*'
+ * @return CRM_Core_Resources_Bundle
+ */
+ public static function createBasicBundle($name, $init = NULL, $types = NULL) {
+ $bundle = new CRM_Core_Resources_Bundle($name, $types);
+ if ($init !== NULL) {
+ $init($bundle);
+ }
+ CRM_Utils_Hook::alterBundle($bundle);
+ $bundle->fillDefaults();
+ return $bundle;
+ }
+