You are here

function commerce_file_field_load in Commerce File 7

Implements hook_field_load().

File

includes/commerce_file.field.inc, line 140
Implement an commerce_file field, based on the file module's file field.

Code

function commerce_file_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) {
  file_field_load($entity_type, $entities, $field, $instances, $langcode, $items, $age);
  foreach ($entities as $id => $entity) {
    foreach ($items[$id] as $delta => $item) {
      if (isset($item) && !empty($item['fid'])) {

        // Unserialize the data array if necessary.
        if (empty($item['data'])) {
          $items[$id][$delta]['data'] = array();
        }
        elseif (!is_array($item['data'])) {
          $items[$id][$delta]['data'] = unserialize($item['data']);
        }
      }
    }
  }
}