X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FPseudoConstant.php;h=843fd7099e18df563f477cc70ad3591bf2da1e83;hb=63d7640448cd41cda34b2851ffa5408e01748fa0;hp=255594e4659fb8f5eaa5c1c91d5744c8f097a9b4;hpb=1590080269b93b1f65d9f9b9211f246c38bfcfd2;p=civicrm-core.git diff --git a/CRM/Core/PseudoConstant.php b/CRM/Core/PseudoConstant.php index 255594e465..843fd7099e 100644 --- a/CRM/Core/PseudoConstant.php +++ b/CRM/Core/PseudoConstant.php @@ -85,7 +85,7 @@ class CRM_Core_PseudoConstant { * RelationshipType * @var array */ - private static $relationshipType; + private static $relationshipType = []; /** * Civicrm groups that are not smart groups @@ -185,7 +185,7 @@ class CRM_Core_PseudoConstant { // Historically this was 'false' but according to the notes in // CRM_Core_DAO::buildOptionsContext it should be context dependent. // timidly changing for 'search' only to fix world_region in search options. - $localizeDefault = in_array($context, ['search']) ? TRUE : FALSE; + $localizeDefault = in_array($context, ['search']); // Merge params with defaults $params += [ 'grouping' => FALSE, @@ -211,15 +211,15 @@ class CRM_Core_PseudoConstant { $dao = new $daoName(); $fieldSpec = $dao->getFieldSpec($fieldName); - // Ensure we have the canonical name for this field - $fieldName = CRM_Utils_Array::value('name', $fieldSpec, $fieldName); - // Return false if field doesn't exist. if (empty($fieldSpec)) { return FALSE; } - elseif (!empty($fieldSpec['pseudoconstant'])) { + // Ensure we have the canonical name for this field + $fieldName = $fieldSpec['name'] ?? $fieldName; + + if (!empty($fieldSpec['pseudoconstant'])) { $pseudoconstant = $fieldSpec['pseudoconstant']; // if callback is specified.. @@ -232,9 +232,9 @@ class CRM_Core_PseudoConstant { // Merge params with schema defaults $params += [ - 'condition' => CRM_Utils_Array::value('condition', $pseudoconstant, []), - 'keyColumn' => CRM_Utils_Array::value('keyColumn', $pseudoconstant), - 'labelColumn' => CRM_Utils_Array::value('labelColumn', $pseudoconstant), + 'condition' => $pseudoconstant['condition'] ?? [], + 'keyColumn' => $pseudoconstant['keyColumn'] ?? NULL, + 'labelColumn' => $pseudoconstant['labelColumn'] ?? NULL, ]; // Fetch option group from option_value table @@ -397,7 +397,7 @@ class CRM_Core_PseudoConstant { if ($values === FALSE) { return FALSE; } - return CRM_Utils_Array::value($key, $values); + return $values[$key] ?? NULL; } /** @@ -417,7 +417,7 @@ class CRM_Core_PseudoConstant { if ($values === FALSE) { return FALSE; } - return CRM_Utils_Array::value($key, $values); + return $values[$key] ?? NULL; } /** @@ -654,7 +654,7 @@ class CRM_Core_PseudoConstant { * array reference of all State/Provinces. */ public static function &stateProvince($id = FALSE, $limit = TRUE) { - if (($id && !CRM_Utils_Array::value($id, self::$stateProvince)) || !self::$stateProvince || !$id) { + if (($id && empty(self::$stateProvince[$id])) || !self::$stateProvince || !$id) { $whereClause = FALSE; if ($limit) { $countryIsoCodes = self::countryIsoCode(); @@ -791,7 +791,7 @@ WHERE id = %1"; * array reference of all countries. */ public static function country($id = FALSE, $applyLimit = TRUE) { - if (($id && !CRM_Utils_Array::value($id, self::$country)) || !self::$country || !$id) { + if (($id && empty(self::$country[$id])) || !self::$country || !$id) { $config = CRM_Core_Config::singleton(); $limitCodes = []; @@ -824,7 +824,7 @@ WHERE id = %1"; $countryIsoCodes = self::countryIsoCode(); $defaultID = array_search(CRM_Core_BAO_Country::defaultContactCountry(), $countryIsoCodes); if ($defaultID !== FALSE) { - $default[$defaultID] = CRM_Utils_Array::value($defaultID, self::$country); + $default[$defaultID] = self::$country[$defaultID] ?? NULL; self::$country = $default + self::$country; } } @@ -1006,9 +1006,9 @@ WHERE id = %1"; * @return array * array reference of all relationship types. */ - public static function &relationshipType($valueColumnName = 'label', $reset = FALSE, $isActive = 1) { + public static function relationshipType($valueColumnName = 'label', $reset = FALSE, $isActive = 1) { $cacheKey = $valueColumnName . '::' . $isActive; - if (!CRM_Utils_Array::value($cacheKey, self::$relationshipType) || $reset) { + if (!isset(self::$relationshipType[$cacheKey]) || $reset) { self::$relationshipType[$cacheKey] = []; //now we have name/label columns CRM-3336 @@ -1151,7 +1151,7 @@ WHERE id = %1"; 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 && CRM_Utils_Array::value($id, self::$paymentProcessorType[$cacheKey])) { + if ($id && !empty(self::$paymentProcessorType[$cacheKey][$id])) { return self::$paymentProcessorType[$cacheKey][$id]; } return self::$paymentProcessorType[$cacheKey]; @@ -1393,12 +1393,12 @@ WHERE id = %1 $index = $filter['greeting_type'] . '_' . $columnName; // also add contactType to the array - $contactType = CRM_Utils_Array::value('contact_type', $filter); + $contactType = $filter['contact_type'] ?? NULL; if ($contactType) { $index .= '_' . $contactType; } - if (!CRM_Utils_Array::value($index, Civi::$statics[__CLASS__]['greeting'])) { + if (empty(Civi::$statics[__CLASS__]['greeting'][$index])) { $filterCondition = NULL; if ($contactType) { $filterVal = 'v.filter ='; @@ -1478,7 +1478,7 @@ WHERE id = %1 self::$accountOptionValues[$cacheKey] = CRM_Core_OptionGroup::values($optionGroupName, FALSE, FALSE, FALSE, $condition); } if ($id) { - return CRM_Utils_Array::value($id, self::$accountOptionValues[$cacheKey]); + return self::$accountOptionValues[$cacheKey][$id] ?? NULL; } return self::$accountOptionValues[$cacheKey];