From a243e821fa8c19f5cdaae5af0495fcccdda70125 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Wed, 14 Oct 2009 14:55:12 +0000 Subject: - Pactch #569224 by bangpound: expose field storage details through field attach. --- modules/simpletest/tests/field_test.module | 43 ++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'modules/simpletest/tests/field_test.module') diff --git a/modules/simpletest/tests/field_test.module b/modules/simpletest/tests/field_test.module index 6bd73c250..cbd1bc07e 100644 --- a/modules/simpletest/tests/field_test.module +++ b/modules/simpletest/tests/field_test.module @@ -666,6 +666,49 @@ function field_test_field_storage_info() { ); } +/** + * Implement hook_field_storage_details(). + */ +function field_test_field_storage_details($field, $instance) { + $details = array(); + + // Add field columns. + $columns = array(); + foreach ((array) $field['columns'] as $column_name => $attributes) { + $columns[$column_name] = $column_name; + } + return array( + 'drupal_variables' => array( + 'field_test_storage_data[FIELD_LOAD_CURRENT]' => $columns, + 'field_test_storage_data[FIELD_LOAD_REVISION]' => $columns, + ), + ); +} + +/** + * Implement hook_field_storage_details_alter(). + * + * @see FieldAttachStorageTestCase::testFieldStorageDetailsAlter() + */ +function field_test_field_storage_details_alter(&$details, $field, $instance) { + + // For testing, storage details are changed only because of the field name. + if ($field['field_name'] == 'field_test_change_my_details') { + $columns = array(); + foreach ((array) $field['columns'] as $column_name => $attributes) { + $columns[$column_name] = $column_name; + } + $details['drupal_variables'] = array( + FIELD_LOAD_CURRENT => array( + 'moon' => $columns, + ), + FIELD_LOAD_REVISION => array( + 'mars' => $columns, + ), + ); + } +} + /** * Helper function: store or retrieve data from the 'storage backend'. */ -- cgit v1.2.3