function entity_metadata_convert_schema in Entity API 7
Converts the schema information available for the given table to property info.
Parameters
$table: The name of the table as used in hook_schema().
Return value
array An array of property info as suiting for hook_entity_property_info().
1 call to entity_metadata_convert_schema()
- EntityDefaultMetadataController::convertSchema in ./
entity.info.inc - Return a set of properties for an entity based on the schema definition
File
- ./
entity.info.inc, line 150 - Provides basic entity property info for entities provided via the CRUD API, as well as property info for all entity types defined by core. For that the respective modules/MODULE.info.inc files are included.
Code
function entity_metadata_convert_schema($table) {
$schema = drupal_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;
}