Skip to content

Commit

Permalink
dev/core#4905 - ImportParser - Use cached function to get custom groups
Browse files Browse the repository at this point in the history
  • Loading branch information
colemanw committed Jan 18, 2024
1 parent fbf738e commit 60a9c5d
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions CRM/Custom/Import/Parser/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,10 @@ private function formatCommonData($params, &$formatted) {
*/
private function getGroupFieldsForImport(int $customGroupID): array {
$importableFields = [];
$fields = (array) CustomField::get(FALSE)
->addSelect('*', 'custom_group_id.is_multiple', 'custom_group_id.name', 'custom_group_id.extends')
->addWhere('custom_group_id', '=', $customGroupID)->execute();
$customGroup = CRM_Core_BAO_CustomGroup::getGroup(['id' => $customGroupID]);

foreach ($fields as $values) {
$datatype = $values['data_type'] ?? NULL;
if ($datatype === 'File') {
foreach ($customGroup['fields'] as $values) {
if ($values['data_type'] === 'File') {
continue;
}
/* generate the key for the fields array */
Expand All @@ -206,10 +203,10 @@ private function getGroupFieldsForImport(int $customGroupID): array {
'is_search_range' => $values['is_search_range'],
'date_format' => $values['date_format'],
'time_format' => $values['time_format'],
'extends' => $values['custom_group_id.extends'],
'extends' => $customGroup['extends'],
'custom_group_id' => $customGroupID,
'custom_group_id.name' => $values['custom_group_id.name'],
'is_multiple' => $values['custom_group_id.is_multiple'],
'custom_group_id.name' => $customGroup['name'],
'is_multiple' => $customGroup['is_multiple'],
];
}
return $importableFields;
Expand Down

0 comments on commit 60a9c5d

Please sign in to comment.