3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
21 * This class holds all the Pseudo constants that are specific to the civimember component. This avoids
22 * polluting the core class and isolates the mass mailer class
24 class CRM_Member_PseudoConstant
extends CRM_Core_PseudoConstant
{
30 private static $membershipType;
36 private static $membershipStatus;
39 * Get all the membership types.
46 * array reference of all membership types if any
48 public static function membershipType($id = NULL, $force = TRUE) {
49 if (!self
::$membershipType ||
$force) {
50 CRM_Core_PseudoConstant
::populate(self
::$membershipType,
51 'CRM_Member_DAO_MembershipType',
52 FALSE, 'name', 'is_active', NULL, 'weight', 'id'
56 if (array_key_exists($id, self
::$membershipType)) {
57 return self
::$membershipType[$id];
64 return self
::$membershipType;
68 * Get all the membership statuss.
73 * @param string $column
76 * @param bool $allStatus
79 * array reference of all membership statuses if any
81 public static function &membershipStatus($id = NULL, $cond = NULL, $column = 'name', $force = FALSE, $allStatus = FALSE) {
82 if (self
::$membershipStatus === NULL) {
83 self
::$membershipStatus = [];
88 $cacheKey .= "_{$cond}";
90 if (!isset(self
::$membershipStatus[$cacheKey]) ||
$force) {
91 CRM_Core_PseudoConstant
::populate(self
::$membershipStatus[$cacheKey],
92 'CRM_Member_DAO_MembershipStatus',
93 $allStatus, $column, 'is_active', $cond, 'weight'
99 $value = self
::$membershipStatus[$cacheKey][$id] ??
NULL;
102 $value = self
::$membershipStatus[$cacheKey];
109 * Flush given pseudoconstant so it can be reread from db
110 * next time it's requested.
113 * @param bool|string $name pseudoconstant to be flushed
115 public static function flush($name = 'cache') {
116 if (isset(self
::$
$name)) {
119 // The preferred source of membership pseudoconstants is in fact the Core class.
120 // which buildOptions accesses - better flush that too.
121 CRM_Core_PseudoConstant
::flush();