function field_test_field_storage_load in Drupal 7
Implements hook_field_storage_load().
File
- modules/
field/ tests/ field_test.storage.inc, line 83 - Defines a field storage backend.
Code
function field_test_field_storage_load($entity_type, $entities, $age, $fields, $options) {
$data = _field_test_storage_data();
$load_current = $age == FIELD_LOAD_CURRENT;
foreach ($fields as $field_id => $ids) {
$field = field_info_field_by_id($field_id);
$field_name = $field['field_name'];
$field_data = $data[$field['id']];
$sub_table = $load_current ? 'current' : 'revisions';
$delta_count = array();
foreach ($field_data[$sub_table] as $row) {
if ($row->type == $entity_type && (!$row->deleted || $options['deleted'])) {
if ($load_current && in_array($row->entity_id, $ids) || !$load_current && in_array($row->revision_id, $ids)) {
if (in_array($row->language, field_available_languages($entity_type, $field))) {
if (!isset($delta_count[$row->entity_id][$row->language])) {
$delta_count[$row->entity_id][$row->language] = 0;
}
if ($field['cardinality'] == FIELD_CARDINALITY_UNLIMITED || $delta_count[$row->entity_id][$row->language] < $field['cardinality']) {
$item = array();
foreach ($field['columns'] as $column => $attributes) {
$item[$column] = $row->{$column};
}
$entities[$row->entity_id]->{$field_name}[$row->language][] = $item;
$delta_count[$row->entity_id][$row->language]++;
}
}
}
}
}
}
}