Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/core#4905 - Delete unused buildGroupTree function #29099

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 0 additions & 81 deletions CRM/Core/BAO/CustomGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -2135,87 +2135,6 @@ public static function getMultipleFieldGroup() {
return $multipleGroup;
}

/**
* Build the metadata tree for the custom group.
*
* @internal - function is temporarily public but will be private again
* once separated function disentangled.
*
* @param string $entityType
* @param array $toReturn
* @param array $subTypes
* @param string $queryString
* @param array $params
* @param string $subType
*
* @return array
* @throws \CRM_Core_Exception
*/
public static function buildGroupTree($entityType, $toReturn, $subTypes, $queryString, $params, $subType) {
$groupTree = $multipleFieldGroups = [];
$crmDAO = CRM_Core_DAO::executeQuery($queryString, $params);
$customValueTables = [];

// process records
while ($crmDAO->fetch()) {
// get the id's
$groupID = $crmDAO->civicrm_custom_group_id;
$fieldId = $crmDAO->civicrm_custom_field_id;
if ($crmDAO->civicrm_custom_group_is_multiple) {
$multipleFieldGroups[$groupID] = $crmDAO->civicrm_custom_group_table_name;
}
// create an array for groups if it does not exist
if (!array_key_exists($groupID, $groupTree)) {
$groupTree[$groupID] = [];
$groupTree[$groupID]['id'] = $groupID;

// populate the group information
foreach ($toReturn['custom_group'] as $fieldName) {
$fullFieldName = "civicrm_custom_group_$fieldName";
if ($fieldName == 'id' ||
is_null($crmDAO->$fullFieldName)
) {
continue;
}
// CRM-5507
// This is an old bit of code - per the CRM number & probably does not work reliably if
// that one contact sub-type exists.
if ($fieldName == 'extends_entity_column_value' && !empty($subTypes[0])) {
$groupTree[$groupID]['subtype'] = self::validateSubTypeByEntity($entityType, $subType);
}
$groupTree[$groupID][$fieldName] = $crmDAO->$fullFieldName;
}
$groupTree[$groupID]['fields'] = [];

$customValueTables[$crmDAO->civicrm_custom_group_table_name] = [];
}

// add the fields now (note - the query row will always contain a field)
// we only reset this once, since multiple values come is as multiple rows
if (!array_key_exists($fieldId, $groupTree[$groupID]['fields'])) {
$groupTree[$groupID]['fields'][$fieldId] = [];
}

$customValueTables[$crmDAO->civicrm_custom_group_table_name][$crmDAO->civicrm_custom_field_column_name] = 1;
$groupTree[$groupID]['fields'][$fieldId]['id'] = $fieldId;
// populate information for a custom field
foreach ($toReturn['custom_field'] as $fieldName) {
$fullFieldName = "civicrm_custom_field_$fieldName";
if ($fieldName == 'id' ||
is_null($crmDAO->$fullFieldName)
) {
continue;
}
$groupTree[$groupID]['fields'][$fieldId][$fieldName] = $crmDAO->$fullFieldName;
}
}

if (!empty($customValueTables)) {
$groupTree['info'] = ['tables' => $customValueTables];
}
return [$multipleFieldGroups, $groupTree];
}

/**
* Use APIv4 getFields (or self::getExtendsEntityColumnValueOptions) instead of this beast.
* @deprecated
Expand Down