Skip to content

Commit

Permalink
[#137] Copy missing core function
Browse files Browse the repository at this point in the history
  • Loading branch information
jensschuppe committed Jul 22, 2024
1 parent 5253722 commit a445ee7
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 a445ee7

Please sign in to comment.