From 7f2b2c0d396917aa05b7c7a54f356e0d6992ac38 Mon Sep 17 00:00:00 2001 From: Joe Murray Date: Tue, 14 Jul 2015 10:18:20 -0400 Subject: [PATCH] Cached return value for getAvailableFinancialTypes added static var $_availableFinancialTypes, and parameter $resetCache, plus processing --- CRM/Financial/BAO/FinancialType.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/CRM/Financial/BAO/FinancialType.php b/CRM/Financial/BAO/FinancialType.php index 8d1297200c..9433386d19 100644 --- a/CRM/Financial/BAO/FinancialType.php +++ b/CRM/Financial/BAO/FinancialType.php @@ -38,6 +38,11 @@ class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType { * Static holder for the default LT. */ static $_defaultContributionType = NULL; + + /** + * Statid cache holder of available financial types for this session + */ + static $_availableFinancialTypes = NULL; /** * Class constructor. @@ -228,20 +233,27 @@ class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType { ); } - public static function getAvailableFinancialTypes(&$financialTypes = NULL, $action = 'view') { + public static function getAvailableFinancialTypes(&$financialTypes = NULL, $action = 'view', $resetCache = FALSE) { if (empty($financialTypes)) { $financialTypes = CRM_Contribute_PseudoConstant::financialType(); } if (!self::isACLFinancialTypeStatus()) { return $financialTypes; + } else { + // check cached value + if (!empty($_availableFinancialTypes) && !$reset) { + return $_availableFinancialTypes; + } } foreach ($financialTypes as $finTypeId => $type) { if (!CRM_Core_Permission::check($action . ' contributions of type ' . $type)) { unset($financialTypes[$finTypeId]); } } + $_availableFinancialTypes = $financialTypes; return $financialTypes; } + public static function getAvailableMembershipTypes(&$membershipTypes = NULL, $action = 'view') { if (empty($membershipTypes)) { $membershipTypes = CRM_Member_PseudoConstant::membershipType(); -- 2.25.1