Support custom fields CRM-12464
[civicrm-core.git] / CRM / Core / PseudoConstant.php
index d70e769ac62d8c8f24bdbe112d6418d0c4739c8e..06055036670f86751afd901a858fca1fd4a9be3b 100644 (file)
@@ -219,6 +219,21 @@ class CRM_Core_PseudoConstant {
    * @static
    */
   public static function get($daoName, $fieldName, $params = array()) {
+    $flip = !empty($params['flip']);
+
+    // Custom fields are not in the schema
+    if (strpos($fieldName, 'custom') === 0) {
+      $dao = new CRM_Core_DAO_CustomField;
+      $dao->id = (int) substr($fieldName, 7);
+      $dao->find(TRUE);
+      $customField = (array) $dao;
+      $dao->free();
+      $output = array();
+      CRM_Core_BAO_CustomField::buildOption($customField, $output);
+      return $flip ? array_flip($output) : $output;
+    }
+
+    // Core field: load schema
     $dao = new $daoName;
     $fields = $dao->fields();
     $fieldKeys = $dao->fieldKeys();
@@ -228,7 +243,6 @@ class CRM_Core_PseudoConstant {
       return FALSE;
     }
     $fieldSpec = $fields[$fieldKey];
-    $flip = !empty($params['flip']);
 
     // If the field is an enum, explode the enum definition and return the array.
     if (isset($fieldSpec['enumValues'])) {
@@ -1261,6 +1275,7 @@ WHERE  id = %1";
   }
 
   /**
+   * DEPRECATED. Please use the buildOptions() method in the appropriate BAO object.
    * Get all active payment processors
    *
    * The static array paymentProcessor is returned
@@ -1295,7 +1310,7 @@ WHERE  id = %1";
   }
 
   /**
-   * Get all active payment processors
+   * DEPRECATED. Please use the buildOptions() method in the appropriate BAO object.
    *
    * The static array paymentProcessorType is returned
    *