Commit | Line | Data |
---|---|---|
a323ce8a TO |
1 | <?php |
2 | ||
3 | /** | |
4 | * Auto-register "ang/*.ang.php" files. | |
5 | * | |
6 | * @mixinName ang-php | |
7 | * @mixinVersion 1.0.0 | |
5956419b | 8 | * @since 5.45 |
a323ce8a 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 | */ | |
15 | return function ($mixInfo, $bootCache) { | |
16 | ||
17 | /** | |
18 | * @param \Civi\Core\Event\GenericHookEvent $e | |
19 | * @see CRM_Utils_Hook::angularModules() | |
20 | */ | |
21 | Civi::dispatcher()->addListener('hook_civicrm_angularModules', function ($e) use ($mixInfo) { | |
22 | // When deactivating on a polyfill/pre-mixin system, listeners may not cleanup automatically. | |
23 | if (!$mixInfo->isActive() || !is_dir($mixInfo->getPath('ang'))) { | |
24 | return; | |
25 | } | |
26 | ||
27 | $files = (array) glob($mixInfo->getPath('ang/*.ang.php')); | |
28 | foreach ($files as $file) { | |
29 | $name = preg_replace(':\.ang\.php$:', '', basename($file)); | |
30 | $module = include $file; | |
31 | if (empty($module['ext'])) { | |
32 | $module['ext'] = $mixInfo->longName; | |
33 | } | |
34 | $e->angularModules[$name] = $module; | |
35 | } | |
36 | }); | |
37 | ||
38 | }; |