addListener('hook_civicrm_managed', function ($event) use ($mixInfo) { // When deactivating on a polyfill/pre-mixin system, listeners may not cleanup automatically. if (!$mixInfo->isActive()) { return; } if (is_array($event->modules) && !in_array($mixInfo->longName, $event->modules, TRUE)) { return; } $mgdFiles = CRM_Utils_File::findFiles($mixInfo->getPath(), '*.mgd.php'); sort($mgdFiles); foreach ($mgdFiles as $file) { $es = include $file; foreach ($es as $e) { if (empty($e['module'])) { $e['module'] = $mixInfo->longName; } if (empty($e['params']['version'])) { $e['params']['version'] = '3'; } $event->entities[] = $e; } } }); };