You are here

function civicrm_entity_get_field_type in CiviCRM Entity 7

Same name and namespace in other branches
  1. 7.2 civicrm_entity.module \civicrm_entity_get_field_type()

Please document this function.

Parameters

$field_spec:

Return value

array

1 call to civicrm_entity_get_field_type()
civicrm_entity_get_schema in ./civicrm_entity.module
Get schema for entities.

File

./civicrm_entity.module, line 139
Implement CiviCRM entities as a Drupal Entity.

Code

function civicrm_entity_get_field_type($field_spec) {
  if ($field_spec['name'] == 'id') {
    return array(
      'type' => 'serial',
    );
  }
  switch ($field_spec['type']) {
    case CRM_Utils_Type::T_INT:
    case CRM_Utils_Type::T_BOOLEAN:
      return array(
        'type' => 'integer',
      );
    case CRM_Utils_Type::T_MONEY:
    case CRM_Utils_Type::T_FLOAT:
      return array(
        'type' => 'float',
      );
    case CRM_Utils_Type::T_TEXT:
    case CRM_Utils_Type::T_STRING:
    case CRM_Utils_Type::T_LONGTEXT:
    case CRM_Utils_Type::T_CCNUM:
    case CRM_Utils_Type::T_EMAIL:
    case CRM_Utils_Type::T_URL:
      return array(
        'type' => 'text',
      );
    case CRM_Utils_Type::T_DATE:
    case CRM_Utils_Type::T_TIME:
      return array(
        'type' => 'varchar',
        'mysql_type' => 'datetime',
      );
    case CRM_Utils_Type::T_ENUM:
      return array(
        'type' => 'varchar',
        'mysql_type' => 'enum',
      );
    case CRM_Utils_Type::T_BLOB:
    case CRM_Utils_Type::T_MEDIUMBLOB:
      return array(
        'type' => 'blob',
      );
    case CRM_Utils_Type::T_TIMESTAMP:
      return array(
        'type' => 'varchar',
        'mysql_type' => 'timestamp',
      );
  }
  return array(
    'type' => $field_spec['type'],
  );
}