Skip to content

Commit

Permalink
Merge branch 'copyMissingCoreFunction'
Browse files Browse the repository at this point in the history
[#137] Copy missing core function
  • Loading branch information
jensschuppe committed Jul 22, 2024
2 parents ab6f158 + 0f8be14 commit cb20bf7
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Civi/Api4/Service/Spec/Provider/EckEntitySpecProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,26 @@ private static function arrayToField(array $data, string $entityName): FieldSpec
return $field;
}

/**
* Get the data type from an array. Defaults to 'data_type' with fallback to
* mapping for the integer value 'type'
*
* @param array $data
*
* @return string
*/
private static function getDataType(array $data) {
$dataType = $data['data_type'] ?? $data['dataType'] ?? NULL;
if (isset($dataType)) {
return !empty($data['time_format']) ? 'Timestamp' : $dataType;
}

$dataTypeInt = $data['type'] ?? NULL;
$dataTypeName = \CRM_Utils_Type::typeToString($dataTypeInt);

return $dataTypeName === 'Int' ? 'Integer' : $dataTypeName;
}

/**
* Copied from \Civi\Api4\Service\Spec\SpecFormatter
*
Expand Down

0 comments on commit cb20bf7

Please sign in to comment.