From: eileen Date: Fri, 11 Mar 2016 01:23:50 +0000 (+1300) Subject: CRM-18213 remove hard-coding of DAO names X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=8485f8e7bafb56639955c3f82fed3eae7dab1b94;p=civicrm-core.git CRM-18213 remove hard-coding of DAO names --- diff --git a/CRM/Logging/Differ.php b/CRM/Logging/Differ.php index c6cc7530c7..77d2caf1c1 100644 --- a/CRM/Logging/Differ.php +++ b/CRM/Logging/Differ.php @@ -257,25 +257,8 @@ WHERE lt.log_conn_id = %1 AND static $titles = array(); static $values = array(); - // FIXME: split off the table → DAO mapping to a GenCode-generated class - static $daos = array( - 'civicrm_address' => 'CRM_Core_DAO_Address', - 'civicrm_contact' => 'CRM_Contact_DAO_Contact', - 'civicrm_email' => 'CRM_Core_DAO_Email', - 'civicrm_im' => 'CRM_Core_DAO_IM', - 'civicrm_openid' => 'CRM_Core_DAO_OpenID', - 'civicrm_phone' => 'CRM_Core_DAO_Phone', - 'civicrm_website' => 'CRM_Core_DAO_Website', - 'civicrm_contribution' => 'CRM_Contribute_DAO_Contribution', - 'civicrm_note' => 'CRM_Core_DAO_Note', - 'civicrm_relationship' => 'CRM_Contact_DAO_Relationship', - 'civicrm_activity' => 'CRM_Activity_DAO_Activity', - 'civicrm_case' => 'CRM_Case_DAO_Case', - ); - if (!isset($titles[$table]) or !isset($values[$table])) { - - if (in_array($table, array_keys($daos))) { + if (($tableDAO = CRM_Core_DAO_AllCoreTables::getClassForTable($table)) != FALSE) { // FIXME: these should be populated with pseudo constants as they // were at the time of logging rather than their current values // FIXME: Use *_BAO:buildOptions() method rather than pseudoconstants & fetch programmatically @@ -311,7 +294,7 @@ WHERE lt.log_conn_id = %1 AND break; } - $dao = new $daos[$table](); + $dao = new $tableDAO(); foreach ($dao->fields() as $field) { $titles[$table][$field['name']] = CRM_Utils_Array::value('title', $field);