diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-10-14 14:55:12 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-10-14 14:55:12 +0000 |
commit | a243e821fa8c19f5cdaae5af0495fcccdda70125 (patch) | |
tree | bda3f7e669281b2bd2d2d49fdb7a44c296d2d92e /modules/simpletest | |
parent | 7a9fc8a33d49badf34b6f41bed978a2aad004745 (diff) | |
download | brdo-a243e821fa8c19f5cdaae5af0495fcccdda70125.tar.gz brdo-a243e821fa8c19f5cdaae5af0495fcccdda70125.tar.bz2 |
- Pactch #569224 by bangpound: expose field storage details through field attach.
Diffstat (limited to 'modules/simpletest')
-rw-r--r-- | modules/simpletest/tests/field_test.module | 43 |
1 files changed, 43 insertions, 0 deletions
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 @@ -667,6 +667,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'. */ function _field_test_storage_data($data = NULL) { |