From: Coleman Watts Date: Tue, 29 Nov 2022 19:37:43 +0000 (-0500) Subject: FieldSpec - Generate better default field titles for DAOs X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=9740402936ba4d4cd7ae8ea343e8f2bb828884b4;p=civicrm-core.git FieldSpec - Generate better default field titles for DAOs --- diff --git a/CRM/Core/CodeGen/Specification.php b/CRM/Core/CodeGen/Specification.php index 44309594fb..0d4fb20c92 100644 --- a/CRM/Core/CodeGen/Specification.php +++ b/CRM/Core/CodeGen/Specification.php @@ -536,24 +536,23 @@ class CRM_Core_CodeGen_Specification { * @return string */ public function composeTitle($name) { + $substitutions = [ + 'is_active' => 'Enabled', + ]; + if (isset($substitutions[$name])) { + return $substitutions[$name]; + } $names = explode('_', strtolower($name)); - $title = ''; - for ($i = 0; $i < count($names); $i++) { - if ($names[$i] === 'id' || $names[$i] === 'is') { - // id's do not get titles - return NULL; - } - - if ($names[$i] === 'im') { - $names[$i] = 'IM'; + $allCaps = ['im', 'id']; + foreach ($names as $i => $str) { + if (in_array($str, $allCaps, TRUE)) { + $names[$i] = strtoupper($str); } else { - $names[$i] = ucfirst(trim($names[$i])); + $names[$i] = ucfirst(trim($str)); } - - $title = $title . ' ' . $names[$i]; } - return trim($title); + return trim(implode(' ', $names)); } /**