You are here

function civicrm_entity_metadata_convert_schema in CiviCRM Entity 7.2

Same name and namespace in other branches
  1. 7 civicrm_entity_metadata_controller.inc \civicrm_entity_metadata_convert_schema()

Converts schema info for table to property info.

This is based on the CiviCRM get schema function and is a very limited implementation.

Parameters

string $table: The name of the table as used in hook_schema().

Return value

array Property info suitable for hook_entity_property_info().

1 call to civicrm_entity_metadata_convert_schema()
CivicrmEntityMetadataController::convertSchema in ./civicrm_entity_metadata_controller.inc
Return a set of properties for an entity based on the schema definition.

File

./civicrm_entity_metadata_controller.inc, line 35
Provides Entity metadata integration.

Code

function civicrm_entity_metadata_convert_schema($table) {
  $schema = civicrm_entity_get_schema($table);
  $properties = array();
  foreach ($schema['fields'] as $name => $info) {
    if ($type = _entity_metadata_convert_schema_type($info['type'])) {
      $properties[$name] = array(
        'type' => $type,
        'label' => drupal_ucfirst($name),
        'schema field' => $name,
      );
      if ($info['type'] == 'serial') {
        $properties[$name]['validation callback'] = 'entity_metadata_validate_integer_positive';
      }
    }
  }
  return $properties;
}