From 97afa853ffddeb71df4e1d2d228eea2ece08e43e Mon Sep 17 00:00:00 2001 From: Allen Shaw Date: Wed, 1 May 2013 11:13:30 -0700 Subject: [PATCH] Refactored out of CRM_Core_PseudoConstant: getBatchType(), getBatchStatus(). CRM-12464 ---------------------------------------- * CRM-12464: http://issues.civicrm.org/jira/browse/CRM-12464 --- CRM/Batch/BAO/Batch.php | 4 +- CRM/Batch/Form/Batch.php | 3 +- CRM/Core/PseudoConstant.php | 50 ------------------- tests/phpunit/CRM/Core/PseudoConstantTest.php | 10 ++++ xml/schema/Batch/Batch.xml | 6 +++ 5 files changed, 20 insertions(+), 53 deletions(-) diff --git a/CRM/Batch/BAO/Batch.php b/CRM/Batch/BAO/Batch.php index d203cbd134..706e4b93f1 100644 --- a/CRM/Batch/BAO/Batch.php +++ b/CRM/Batch/BAO/Batch.php @@ -285,8 +285,8 @@ class CRM_Batch_BAO_Batch extends CRM_Batch_DAO_Batch { $links = self::links(); } - $batchTypes = CRM_Core_PseudoConstant::getBatchType(); - $batchStatus = CRM_Core_PseudoConstant::getBatchStatus(); + $batchTypes = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'type_id'); + $batchStatus = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id'); $paymentInstrument = CRM_Contribute_PseudoConstant::paymentInstrument(); $results = array(); diff --git a/CRM/Batch/Form/Batch.php b/CRM/Batch/Form/Batch.php index aa52c54750..c722d7b45f 100644 --- a/CRM/Batch/Form/Batch.php +++ b/CRM/Batch/Form/Batch.php @@ -63,7 +63,8 @@ class CRM_Batch_Form_Batch extends CRM_Admin_Form { $attributes = CRM_Core_DAO::getAttribute('CRM_Batch_DAO_Batch'); $this->add('text', 'title', ts('Batch Name'), $attributes['name'], TRUE); - $batchTypes = CRM_Core_PseudoConstant::getBatchType(); + $batchTypes = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'type_id'); + // unset non-related types unset($batchTypes[3]); unset($batchTypes[4]); diff --git a/CRM/Core/PseudoConstant.php b/CRM/Core/PseudoConstant.php index f4a8e4bf25..a6e0a48a11 100644 --- a/CRM/Core/PseudoConstant.php +++ b/CRM/Core/PseudoConstant.php @@ -287,20 +287,6 @@ class CRM_Core_PseudoConstant { */ private static $batchModes; - /** - * batch type options - * @var array - * @static - */ - private static $batchTypes; - - /** - * batch status options - * @var array - * @static - */ - private static $batchStatues; - /** * contact Type * @var array @@ -1978,42 +1964,6 @@ WHERE id = %1 return self::$batchModes; } - /** - * Get all batch types - * - * The static array batchTypes - * - * @access public - * @static - * - * @return array - array reference of all batch types - */ - public static function &getBatchType() { - if (!self::$batchTypes) { - self::$batchTypes = CRM_Core_OptionGroup::values('batch_type'); - } - - return self::$batchTypes; - } - - /** - * Get all batch statuses - * - * The static array batchStatues - * - * @access public - * @static - * - * @return array - array reference of all batch statuses - */ - public static function &getBatchStatus() { - if (!self::$batchStatues) { - self::$batchStatues = CRM_Core_OptionGroup::values('batch_status'); - } - - return self::$batchStatues; - } - /* * The static array contactType is returned * diff --git a/tests/phpunit/CRM/Core/PseudoConstantTest.php b/tests/phpunit/CRM/Core/PseudoConstantTest.php index feb295d87a..84b1d05cc1 100644 --- a/tests/phpunit/CRM/Core/PseudoConstantTest.php +++ b/tests/phpunit/CRM/Core/PseudoConstantTest.php @@ -50,6 +50,16 @@ class CRM_Core_PseudoConstantTest extends CiviUnitTestCase { // - sample: Any one value which is expected in the list of option values. // - max: integer (default = 10) maximum number of option values expected. $fields = array( + 'CRM_Batch_DAO_Batch' => array( + array( + 'fieldName' => 'type_id', + 'sample' => 'Membership', + ), + array( + 'fieldName' => 'status_id', + 'sample' => 'Reopened', + ), + ), 'CRM_Project_DAO_Task' => array( array( 'fieldName' => 'priority_id', diff --git a/xml/schema/Batch/Batch.xml b/xml/schema/Batch/Batch.xml index a7f5516ae6..11068122b0 100644 --- a/xml/schema/Batch/Batch.xml +++ b/xml/schema/Batch/Batch.xml @@ -114,12 +114,18 @@ true fk to Batch Status options in civicrm_option_values 4.2 + + batch_status + type_id int unsigned fk to Batch Type options in civicrm_option_values 4.2 + + batch_type + mode_id -- 2.25.1