Skip to content

Commit

Permalink
Merge pull request #25080 from colemanw/titleSpec
Browse files Browse the repository at this point in the history
FieldSpec - Generate better default field titles for DAOs
  • Loading branch information
eileenmcnaughton authored Nov 29, 2022
2 parents 1c364c6 + 9740402 commit c265546
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions CRM/Core/CodeGen/Specification.php
Original file line number Diff line number Diff line change
Expand Up @@ -536,24 +536,23 @@ private function getPhpNullable($fieldXML) {
* @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));
}

/**
Expand Down

0 comments on commit c265546

Please sign in to comment.