*/
private static $country;
- /**
- * CountryIsoCode.
- * @var array
- */
- private static $countryIsoCode;
-
/**
* group
* @var array
*/
private static $currencyCode;
- /**
- * Payment processor
- * @var array
- */
- private static $paymentProcessor;
-
- /**
- * Payment processor types
- * @var array
- */
- private static $paymentProcessorType;
-
- /**
- * World Region
- * @var array
- */
- private static $worldRegions;
-
- /**
- * activity status
- * @var array
- * @deprecated Please use the buildOptions() method in the appropriate BAO object.
- */
- private static $activityStatus;
-
- /**
- * Visibility
- * @var array
- */
- private static $visibility;
-
- /**
- * Greetings
- * @var array
- */
- private static $greeting;
-
/**
* Extensions of type module
* @var array
}
/**
- * Flush given pseudoconstant so it can be reread from db.
- * nex time it's requested.
+ * Flush static array cache.
*
* @param bool|string $name pseudoconstant to be flushed
*/
/**
* Get all the State/Province abbreviations from the database for the specified country.
+ * @deprecated
*
* @param int $countryID
*
* array of all State/Province abbreviations for the given country.
*/
public static function stateProvinceAbbreviationForCountry($countryID) {
- if (!isset(\Civi::$statics[__CLASS__]['stateProvinceAbbreviationForCountry'][$countryID])) {
- \Civi::$statics[__CLASS__]['stateProvinceAbbreviationForCountry'][$countryID] = [];
- }
- self::populate(\Civi::$statics[__CLASS__]['stateProvinceAbbreviationForCountry'][$countryID], 'CRM_Core_DAO_StateProvince', TRUE, 'abbreviation', 'is_active', "country_id = " . (int) $countryID, 'abbreviation');
- return \Civi::$statics[__CLASS__]['stateProvinceAbbreviationForCountry'][$countryID];
+ CRM_Core_Error::deprecatedFunctionWarning('API');
+ $abbrs = [];
+ self::populate($abbrs, 'CRM_Core_DAO_StateProvince', TRUE, 'abbreviation', 'is_active', "country_id = " . (int) $countryID, 'abbreviation');
+ return $abbrs;
}
/**
* Get all the State/Province abbreviations from the database for the default country.
+ * @deprecated
*
* @return array
* array of all State/Province abbreviations for the given country.
*/
public static function stateProvinceAbbreviationForDefaultCountry() {
- return CRM_Core_PseudoConstant::stateProvinceAbbreviationForCountry(Civi::settings()->get('defaultContactCountry'));
+ $countryID = Civi::settings()->get('defaultContactCountry');
+ $abbrs = [];
+ self::populate($abbrs, 'CRM_Core_DAO_StateProvince', TRUE, 'abbreviation', 'is_active', "country_id = " . (int) $countryID, 'abbreviation');
+ return $abbrs;
}
/**
/**
* Get all the country ISO Code abbreviations from the database.
*
- * The static array countryIsoCode is returned, and if it's
- * called the first time, the <b>Country DAO</b> is used
- * to get all the countries' ISO codes.
- *
- * Note: any database errors will be trapped by the DAO.
- *
- *
* @param bool $id
*
* @return array
- * array reference of all country ISO codes.
*/
- public static function &countryIsoCode($id = FALSE) {
- if (!self::$countryIsoCode) {
- self::populate(self::$countryIsoCode, 'CRM_Core_DAO_Country', TRUE, 'iso_code');
- }
+ public static function countryIsoCode($id = FALSE) {
+ $values = [];
+ self::populate($values, 'CRM_Core_DAO_Country', TRUE, 'iso_code');
+
if ($id) {
- if (array_key_exists($id, self::$countryIsoCode)) {
- return self::$countryIsoCode[$id];
- }
- else {
- return CRM_Core_DAO::$_nullObject;
- }
+ return $values[$id] ?? NULL;
}
- return self::$countryIsoCode;
+ return $values;
}
/**
*/
public static function allGroup($groupType = NULL, $excludeHidden = TRUE) {
$condition = CRM_Contact_BAO_Group::groupTypeCondition($groupType, $excludeHidden);
- $groupKey = ($groupType ?: 'null') . !empty($excludeHidden);
-
- if (!isset(Civi::$statics[__CLASS__]['groups']['allGroup'][$groupKey])) {
- self::populate(Civi::$statics[__CLASS__]['groups']['allGroup'][$groupKey], 'CRM_Contact_DAO_Group', FALSE, 'title', 'is_active', $condition);
- }
- return Civi::$statics[__CLASS__]['groups']['allGroup'][$groupKey];
+ $values = [];
+ self::populate($values, 'CRM_Contact_DAO_Group', FALSE, 'title', 'is_active', $condition);
+ return $values;
}
/**
/**
* Get all the ISO 4217 currency codes
*
- * so far, we use this for validation only, so there's no point of putting this into the database
- *
- *
* @return array
* array reference of all currency codes
*/
$query = "SELECT name FROM civicrm_currency";
$dao = CRM_Core_DAO::executeQuery($query);
- $currencyCode = [];
while ($dao->fetch()) {
self::$currencyCode[] = $dao->name;
}
* array of all payment processors
*/
public static function paymentProcessor($all = FALSE, $test = FALSE, $additionalCond = NULL) {
- $condition = "is_test = ";
- $condition .= ($test) ? '1' : '0';
+ $condition = 'is_test = ' . ($test ? '1' : '0');
if ($additionalCond) {
$condition .= " AND ( $additionalCond ) ";
// CRM-7178. Make sure we only include payment processors valid in this
// domain
$condition .= " AND domain_id = " . CRM_Core_Config::domainID();
+ $values = [];
+ self::populate($values, 'CRM_Financial_DAO_PaymentProcessor', $all, 'name', 'is_active', $condition, 'is_default desc, name');
- $cacheKey = $condition . '_' . (int) $all;
- if (!isset(self::$paymentProcessor[$cacheKey])) {
- self::populate(self::$paymentProcessor[$cacheKey], 'CRM_Financial_DAO_PaymentProcessor', $all, 'name', 'is_active', $condition, 'is_default desc, name');
- }
-
- return self::$paymentProcessor[$cacheKey];
+ return $values;
}
/**
* array of all payment processor types
*/
public static function &paymentProcessorType($all = FALSE, $id = NULL, $return = 'title') {
- $cacheKey = $id . '_' . $return;
- if (empty(self::$paymentProcessorType[$cacheKey])) {
- self::populate(self::$paymentProcessorType[$cacheKey], 'CRM_Financial_DAO_PaymentProcessorType', $all, $return, 'is_active', NULL, "is_default, $return", 'id');
- }
- if ($id && !empty(self::$paymentProcessorType[$cacheKey][$id])) {
- return self::$paymentProcessorType[$cacheKey][$id];
- }
- return self::$paymentProcessorType[$cacheKey];
+ CRM_Core_Error::deprecatedFunctionWarning('API');
+ $values = [];
+ self::populate($values, 'CRM_Financial_DAO_PaymentProcessorType', $all, $return, 'is_active', NULL, "is_default, $return", 'id');
+ // This is incredibly stupid, but the whole function is deprecated anyway...
+ if ($id && !empty($values[$id])) {
+ return $values[$id];
+ }
+ return $values;
}
/**
* Get all the World Regions from Database.
*
- *
* @param bool $id
*
* @return array
* array reference of all World Regions
*/
- public static function &worldRegion($id = FALSE) {
- if (!self::$worldRegions) {
- self::populate(self::$worldRegions, 'CRM_Core_DAO_Worldregion', TRUE, 'name', NULL, NULL, 'id');
- }
+ public static function worldRegion($id = FALSE) {
+ $values = [];
+ self::populate($values, 'CRM_Core_DAO_Worldregion', TRUE, 'name', NULL, NULL, 'id');
if ($id) {
- if (array_key_exists($id, self::$worldRegions)) {
- return self::$worldRegions[$id];
- }
- else {
- return CRM_Core_DAO::$_nullObject;
- }
+ return $values[$id] ?? NULL;
}
-
- return self::$worldRegions;
+ return $values;
}
/**
*
* Get all Activity Statuses.
*
- * The static array activityStatus is returned
- *
- *
* @param string $column
*
* @return array
- * array reference of all activity statuses
*/
public static function &activityStatus($column = 'label') {
- if (NULL === self::$activityStatus) {
- self::$activityStatus = [];
- }
- if (!array_key_exists($column, self::$activityStatus)) {
- self::$activityStatus[$column] = [];
-
- self::$activityStatus[$column] = CRM_Core_OptionGroup::values('activity_status', FALSE, FALSE, FALSE, NULL, $column);
- }
-
- return self::$activityStatus[$column];
+ return CRM_Core_OptionGroup::values('activity_status', FALSE, FALSE, FALSE, NULL, $column);
}
/**
* @return array
* array reference of all Visibility levels.
*/
- public static function &visibility($column = 'label') {
- if (!isset(self::$visibility)) {
- self::$visibility = [];
- }
-
- if (!isset(self::$visibility[$column])) {
- self::$visibility[$column] = CRM_Core_OptionGroup::values('visibility', FALSE, FALSE, FALSE, NULL, $column);
- }
-
- return self::$visibility[$column];
+ public static function visibility($column = 'label') {
+ return CRM_Core_OptionGroup::values('visibility', FALSE, FALSE, FALSE, NULL, $column);
}
/**