You are here

function field_test_field_attach_delete_bundle in SimpleTest 7

Implement hook_field_attach_delete_bundle().

File

tests/field_test.module, line 1133

Code

function field_test_field_attach_delete_bundle($bundle, $instances) {
  $data = _field_test_storage_data();
  $instances = field_info_instances($bundle);
  foreach ($instances as $field_name => $instance) {
    $field = field_info_field($field_name);
    if ($field['storage']['type'] == 'field_test_storage') {
      $field_data =& $data[$field['id']];
      foreach (array(
        'current',
        'revisions',
      ) as $sub_table) {
        foreach ($field_data[$sub_table] as &$row) {
          if ($row->bundle == $bundle_old) {
            $row->deleted = TRUE;
          }
        }
      }
    }
  }
  _field_test_storage_data($data);
}