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
19 * This class holds all the Pseudo constants that are specific to the civimember component. This avoids
20 * polluting the core class and isolates the mass mailer class
22 class CRM_Member_PseudoConstant
extends CRM_Core_PseudoConstant
{
28 private static $membershipType;
34 private static $membershipStatus;
37 * Get all the membership types.
44 * array reference of all membership types if any
46 public static function membershipType($id = NULL, $force = TRUE) {
47 if (!self
::$membershipType ||
$force) {
48 CRM_Core_PseudoConstant
::populate(self
::$membershipType,
49 'CRM_Member_DAO_MembershipType',
50 FALSE, 'name', 'is_active', NULL, 'weight', 'id'
54 if (array_key_exists($id, self
::$membershipType)) {
55 return self
::$membershipType[$id];
62 return self
::$membershipType;
66 * Get all the membership statuss.
71 * @param string $column
74 * @param bool $allStatus
77 * array reference of all membership statuses if any
79 public static function &membershipStatus($id = NULL, $cond = NULL, $column = 'name', $force = FALSE, $allStatus = FALSE) {
80 if (self
::$membershipStatus === NULL) {
81 self
::$membershipStatus = [];
86 $cacheKey .= "_{$cond}";
88 if (!isset(self
::$membershipStatus[$cacheKey]) ||
$force) {
89 CRM_Core_PseudoConstant
::populate(self
::$membershipStatus[$cacheKey],
90 'CRM_Member_DAO_MembershipStatus',
91 $allStatus, $column, 'is_active', $cond, 'weight'
97 $value = self
::$membershipStatus[$cacheKey][$id] ??
NULL;
100 $value = self
::$membershipStatus[$cacheKey];
107 * Flush given pseudoconstant so it can be reread from db
108 * next time it's requested.
111 * @param bool|string $name pseudoconstant to be flushed
113 public static function flush($name = 'cache') {
114 if (isset(self
::$
$name)) {
117 // The preferred source of membership pseudoconstants is in fact the Core class.
118 // which buildOptions accesses - better flush that too.
119 CRM_Core_PseudoConstant
::flush();