diff --git a/CRM/Eck/BAO/EckEntityType.php b/CRM/Eck/BAO/EckEntityType.php index d2586ae..b2985fd 100644 --- a/CRM/Eck/BAO/EckEntityType.php +++ b/CRM/Eck/BAO/EckEntityType.php @@ -21,12 +21,14 @@ class CRM_Eck_BAO_EckEntityType extends CRM_Eck_DAO_EckEntityType { * @return array[] */ public static function getEntityTypes(): array { - if (!isset(Civi::$statics['EckEntityTypes'])) { - Civi::$statics['EckEntityTypes'] = CRM_Core_DAO::executeQuery( + $entityTypes = Civi::cache('metadata')->get('EckEntityTypes'); + if (!is_array($entityTypes)) { + $entityTypes = CRM_Core_DAO::executeQuery( 'SELECT *, CONCAT("Eck_", name) AS entity_name, CONCAT("civicrm_eck_", LOWER(name)) AS table_name FROM `civicrm_eck_entity_type`;' )->fetchAll(); + Civi::cache('metadata')->set('EckEntityTypes', $entityTypes); } - return Civi::$statics['EckEntityTypes']; + return $entityTypes; } /** diff --git a/eck.php b/eck.php index 49a96a1..38757e4 100644 --- a/eck.php +++ b/eck.php @@ -42,7 +42,10 @@ function eck_civicrm_xmlMenu(&$files) { * * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_managed */ -function eck_civicrm_managed(&$entities) { +function eck_civicrm_managed(&$entities, $modules = NULL) { + if ($modules && !in_array(E::LONG_NAME, $modules, TRUE)) { + return; + } // Scan the managed/ directory for .mgd.php files _eck_civix_civicrm_managed($entities); @@ -202,16 +205,13 @@ function eck_civicrm_post($action, $entity, $id, $object) { CRM_Eck_BAO_EckEntityType::ensureEntityType($object->toArray()); } - // Reset cache of entity types - Civi::$statics['EckEntityTypes'] = NULL; - // Flush schema cache. CRM_Core_DAO_AllCoreTables::reinitializeCache(); Civi::cache('metadata')->clear(); // Refresh managed entities which are autogenerated based on EckEntities // @see eck_civicrm_managed() - \CRM_Core_ManagedEntities::singleton()->reconcile(); + \CRM_Core_ManagedEntities::singleton()->reconcile(E::LONG_NAME); // Flush navigation cache. CRM_Core_BAO_Navigation::resetNavigation();