Expand try-catch to whole function
[civicrm-core.git] / mixin / theme-php@1 / mixin.php
CommitLineData
c2a3d197
TO
1<?php
2
3/**
4 * Auto-register "*.theme.php" files.
5 *
6 * @mixinName theme-php
7 * @mixinVersion 1.0.0
5956419b 8 * @since 5.45
c2a3d197
TO
9 *
10 * @param CRM_Extension_MixInfo $mixInfo
11 * On newer deployments, this will be an instance of MixInfo. On older deployments, Civix may polyfill with a work-a-like.
12 * @param \CRM_Extension_BootCache $bootCache
13 * On newer deployments, this will be an instance of MixInfo. On older deployments, Civix may polyfill with a work-a-like.
14 */
15return function ($mixInfo, $bootCache) {
16
17 /**
18 * @param \Civi\Core\Event\GenericHookEvent $e
19 * @see CRM_Utils_Hook::themes()
20 */
21 Civi::dispatcher()->addListener('hook_civicrm_themes', function ($e) use ($mixInfo) {
22 // When deactivating on a polyfill/pre-mixin system, listeners may not cleanup automatically.
23 if (!$mixInfo->isActive()) {
24 return;
25 }
26 $files = (array) glob($mixInfo->getPath('*.theme.php'));
27 foreach ($files as $file) {
28 $themeMeta = include $file;
29 if (empty($themeMeta['name'])) {
30 $themeMeta['name'] = preg_replace(':\.theme\.php$:', '', basename($file));
31 }
32 if (empty($themeMeta['ext'])) {
33 $themeMeta['ext'] = $mixInfo->longName;
34 }
35 $e->themes[$themeMeta['name']] = $themeMeta;
36 }
37 });
38
39};