From 270d6e7d5a419c48c3632158922310ec9cf54f00 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Thu, 10 Nov 2022 11:39:26 -0500 Subject: [PATCH] Add entity-types-php mixin --- mixin/entity-types-php@1/mixin.php | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 mixin/entity-types-php@1/mixin.php diff --git a/mixin/entity-types-php@1/mixin.php b/mixin/entity-types-php@1/mixin.php new file mode 100644 index 0000000000..8ec4203dfe --- /dev/null +++ b/mixin/entity-types-php@1/mixin.php @@ -0,0 +1,36 @@ +addListener('hook_civicrm_entityTypes', function ($e) use ($mixInfo) { + // When deactivating on a polyfill/pre-mixin system, listeners may not cleanup automatically. + if (!$mixInfo->isActive() || !is_dir($mixInfo->getPath('xml/schema/CRM'))) { + return; + } + + $files = (array) glob($mixInfo->getPath('xml/schema/CRM/*/*.entityType.php')); + foreach ($files as $file) { + $entities = include $file; + foreach ($entities as $entity) { + $e->entityTypes[$entity['class']] = $entity; + } + } + }); + +}; -- 2.25.1