Allow nonstandard apis to declare their dao
authorColeman Watts <coleman@civicrm.org>
Mon, 24 Mar 2014 20:52:30 +0000 (16:52 -0400)
committerColeman Watts <coleman@civicrm.org>
Mon, 24 Mar 2014 20:52:30 +0000 (16:52 -0400)
api/v3/utils.php

index 942df007a67c1ee77e7e27787fa480d691b5557c..993791cf6b9048c94554dc86eb600211a5315666 100644 (file)
@@ -318,7 +318,19 @@ function _civicrm_api3_get_DAO($name) {
   if ($name == 'Im' || $name == 'Acl') {
     $name = strtoupper($name);
   }
-  return CRM_Core_DAO_AllCoreTables::getFullName($name);
+  $dao = CRM_Core_DAO_AllCoreTables::getFullName($name);
+  if ($dao) {
+    return $dao;
+  }
+
+  // Really weird apis can declare their own DAO name. Not sure if this is a good idea...
+  include_once "api/v3/$name.php";
+  $daoFn = "_civicrm_api3_" . _civicrm_api_get_entity_name_from_camel($name) . "_DAO";
+  if (function_exists($daoFn)) {
+    return $daoFn();
+  }
+
+  return NULL;
 }
 
 /**