CRM-13807 - Verify BAO exists in api getBAO
[civicrm-core.git] / api / v3 / utils.php
index 36e84b908049ef1351e0822e90be48a1188d283b..4c7d369978a39270b0d6e900543b73c1b469e1b5 100644 (file)
@@ -307,8 +307,9 @@ function _civicrm_api3_get_DAO($name) {
  */
 function _civicrm_api3_get_BAO($name) {
   $dao = _civicrm_api3_get_DAO($name);
-  $dao = str_replace("DAO", "BAO", $dao);
-  return $dao;
+  $bao = str_replace("DAO", "BAO", $dao);
+  $file = str_replace('_', '/', $dao) . '.php';
+  return file_exists($file) ? $bao : $dao;
 }
 
 /**