4 * Auto-register "*.theme.php" files.
9 * @param CRM_Extension_MixInfo $mixInfo
10 * On newer deployments, this will be an instance of MixInfo. On older deployments, Civix may polyfill with a work-a-like.
11 * @param \CRM_Extension_BootCache $bootCache
12 * On newer deployments, this will be an instance of MixInfo. On older deployments, Civix may polyfill with a work-a-like.
14 return function ($mixInfo, $bootCache) {
17 * @param \Civi\Core\Event\GenericHookEvent $e
18 * @see CRM_Utils_Hook::themes()
20 Civi
::dispatcher()->addListener('hook_civicrm_themes', function ($e) use ($mixInfo) {
21 // When deactivating on a polyfill/pre-mixin system, listeners may not cleanup automatically.
22 if (!$mixInfo->isActive()) {
25 $files = (array) glob($mixInfo->getPath('*.theme.php'));
26 foreach ($files as $file) {
27 $themeMeta = include $file;
28 if (empty($themeMeta['name'])) {
29 $themeMeta['name'] = preg_replace(':\.theme\.php$:', '', basename($file));
31 if (empty($themeMeta['ext'])) {
32 $themeMeta['ext'] = $mixInfo->longName
;
34 $e->themes
[$themeMeta['name']] = $themeMeta;