From cc6443c4963b568404164dacd0636725d87980bd Mon Sep 17 00:00:00 2001 From: kurund Date: Thu, 13 Feb 2014 12:35:04 -0800 Subject: [PATCH] CRM-14181, gencode fixes to generate correct DAO and modified pseudoconstant to handle callback ---------------------------------------- * CRM-14181: migrate enums to varchar in schema for all tables http://issues.civicrm.org/jira/browse/CRM-14181 --- CRM/Core/CodeGen/Specification.php | 2 ++ CRM/Core/PseudoConstant.php | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/CRM/Core/CodeGen/Specification.php b/CRM/Core/CodeGen/Specification.php index a94e3d7e60..5ae770a6a9 100644 --- a/CRM/Core/CodeGen/Specification.php +++ b/CRM/Core/CodeGen/Specification.php @@ -353,6 +353,8 @@ class CRM_Core_CodeGen_Specification { 'nameColumn', // Where clause snippet (will be joined to the rest of the query with AND operator) 'condition', + // callback funtion incase of static arrays + 'callback', ); foreach ($validOptions as $pseudoOption) { if(!empty($fieldXML->pseudoconstant->$pseudoOption)){ diff --git a/CRM/Core/PseudoConstant.php b/CRM/Core/PseudoConstant.php index 98f8558a14..4df5f3b8b3 100644 --- a/CRM/Core/PseudoConstant.php +++ b/CRM/Core/PseudoConstant.php @@ -285,6 +285,15 @@ class CRM_Core_PseudoConstant { elseif (!empty($fieldSpec['pseudoconstant'])) { $pseudoconstant = $fieldSpec['pseudoconstant']; + + // if callback is specified.. + if(!empty($pseudoconstant['callback'])) { + list($className, $fnName) = explode('::', $pseudoconstant['callback']); + if (method_exists($className, $fnName)) { + return call_user_func(array($className, $fnName)); + } + } + // Merge params with schema defaults $params += array( 'condition' => CRM_Utils_Array::value('condition', $pseudoconstant, array()), -- 2.25.1