function views_natural_sort_entity_to_vns in Views Natural Sort 7.2
A helper function for creating a VNS record for storage.
Parameters
object $entity: An object representing an entity.
string $entity_type: The machine name for an entity type.
string $field: The machine name for the field the data belongs to.
Return value
array An array that represents the VNS table row to be inserted.
1 call to views_natural_sort_entity_to_vns()
- views_natural_sort_entity_insert in ./
views_natural_sort.module - Implements hook_entity_insert().
File
- ./
views_natural_sort.module, line 466 - Views Natural Sort module.
Code
function views_natural_sort_entity_to_vns($entity, $entity_type, $field) {
$supported_entity_properties = views_natural_sort_get_views_configurable_properties();
if (empty($supported_entity_properties[$entity_type]) || empty($supported_entity_properties[$entity_type][$field])) {
throw new Exception("{$entity_type} -> {$field} doesn't exist. Cannot create Views Natural Sort record");
}
$entity_info = entity_get_info($entity_type);
$id_field = $entity_info['entity keys']['id'];
return array(
'eid' => $entity->{$id_field},
'entity_type' => $entity_type,
'field' => $field,
'delta' => 0,
'content' => $entity->{$field},
);
}