X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FPseudoConstant.php;h=14e2e7fcf220d826e9af4d437329f7fc442bc5cf;hb=9853731c2578d7eedfc0ec0cb442520081da9966;hp=df29c7f3f5154c47aa08fc3310906e04af617b2b;hpb=b006f4252b4c052d823a7199421ace7ba7d4ab5f;p=civicrm-core.git diff --git a/CRM/Core/PseudoConstant.php b/CRM/Core/PseudoConstant.php index df29c7f3f5..14e2e7fcf2 100644 --- a/CRM/Core/PseudoConstant.php +++ b/CRM/Core/PseudoConstant.php @@ -253,20 +253,6 @@ class CRM_Core_PseudoConstant { 'labelColumn' => CRM_Utils_Array::value('labelColumn', $pseudoconstant), ]; - if ($context == 'abbreviate') { - switch ($fieldName) { - case 'state_province_id': - $params['labelColumn'] = 'abbreviation'; - break; - - case 'country_id': - $params['labelColumn'] = 'iso_code'; - break; - - default: - } - } - // Fetch option group from option_value table if (!empty($pseudoconstant['optionGroupName'])) { if ($context == 'validate') { @@ -300,8 +286,8 @@ class CRM_Core_PseudoConstant { $cacheKey = $daoName . $fieldName . serialize($params); // Retrieve cached options - if (isset(self::$cache[$cacheKey]) && empty($params['fresh'])) { - $output = self::$cache[$cacheKey]; + if (isset(\Civi::$statics[__CLASS__][$cacheKey]) && empty($params['fresh'])) { + $output = \Civi::$statics[__CLASS__][$cacheKey]; } else { $daoName = CRM_Core_DAO_AllCoreTables::getClassForTable($pseudoconstant['table']); @@ -327,6 +313,12 @@ class CRM_Core_PseudoConstant { $params[$nameField] = 'name'; } } + + // Use abbrColum if context is abbreviate + if ($context == 'abbreviate' && (in_array('abbreviation', $availableFields) || !empty($pseudoconstant['abbrColumn']))) { + $params['labelColumn'] = $pseudoconstant['abbrColumn'] ?? 'abbreviation'; + } + // Condition param can be passed as an sql clause string or an array of clauses if (!empty($params['condition'])) { $wheres[] = implode(' AND ', (array) $params['condition']); @@ -386,7 +378,7 @@ class CRM_Core_PseudoConstant { } } CRM_Utils_Hook::fieldOptions($entity, $fieldName, $output, $params); - self::$cache[$cacheKey] = $output; + \Civi::$statics[__CLASS__][$cacheKey] = $output; } return $flip ? array_flip($output) : $output; } @@ -844,9 +836,9 @@ WHERE id = %1"; self::populate(self::$country, 'CRM_Core_DAO_Country', TRUE, 'name', 'is_active', $whereClause); // if default country is set, percolate it to the top - if ($config->defaultContactCountry()) { + if (CRM_Core_BAO_Country::defaultContactCountry()) { $countryIsoCodes = self::countryIsoCode(); - $defaultID = array_search($config->defaultContactCountry(), $countryIsoCodes); + $defaultID = array_search(CRM_Core_BAO_Country::defaultContactCountry(), $countryIsoCodes); if ($defaultID !== FALSE) { $default[$defaultID] = CRM_Utils_Array::value($defaultID, self::$country); self::$country = $default + self::$country;