+ /**
+ * Get all dynamic references to the given table.
+ *
+ * @param string $tableName
+ *
+ * @return array
+ */
+ public static function getDynamicReferencesToTable($tableName) {
+ if (!isset(\Civi::$statics[__CLASS__]['contact_references_dynamic'][$tableName])) {
+ \Civi::$statics[__CLASS__]['contact_references_dynamic'][$tableName] = [];
+ $coreReferences = CRM_Core_DAO::getReferencesToTable($tableName);
+ foreach ($coreReferences as $coreReference) {
+ if ($coreReference instanceof \CRM_Core_Reference_Dynamic) {
+ \Civi::$statics[__CLASS__]['contact_references_dynamic'][$tableName][$coreReference->getReferenceTable()][] = $coreReference->getReferenceKey();
+ }
+ }
+ }
+ return \Civi::$statics[__CLASS__]['contact_references_dynamic'][$tableName];
+ }
+