diff --git a/help/export.html b/help/export.html
index 9118e72..0224b6d 100644
--- a/help/export.html
+++ b/help/export.html
@@ -105,7 +105,10 @@ function mymodule_schema() {
Objects should contain a primary key which is a database identifier primarily used to determine if an object has been written or not. This is required for the default CRUD save callback to work.
object
-The class the object should be created as. Defaults as stdClass.
+The class the object should be created as. If neither this nor 'object class callback' is set, defaults as stdClass.
+
+object class callback
+Function used to get the name of the class the object should be created as. The function receives the loaded object as a parameter. If neither this nor 'object' is set, defaults as stdClass..
can disable
Control whether or not the exportable objects can be disabled. All this does is cause the 'disabled' field on the object to always be set appropriately, and a variable is kept to record the state. Changes made to this state must be handled by the owner of the object. Defaults to TRUE.
diff --git a/includes/export.inc b/includes/export.inc
index fd6797a..6ce7c6c 100644
--- a/includes/export.inc
+++ b/includes/export.inc
@@ -380,7 +380,14 @@ function ctools_export_load_object($table, $type = 'all', $args = array()) {
$status = variable_get($export['status'], array());
// Unpack the results of the query onto objects and cache them.
while ($data = db_fetch_object($result)) {
- $object = _ctools_export_unpack_object($schema, $data, $export['object']);
+ if (isset($schema['export']['object class callback'])) {
+ $function = $schema['export']['object class callback'];
+ $class = $function($data);
+ }
+ else {
+ $class = $schema['export']['object'];
+ }
+ $object = _ctools_export_unpack_object($schema, $data, $class);
$object->table = $table;
$object->type = t('Normal');
$object->export_type = EXPORT_IN_DATABASE;
@@ -629,7 +636,14 @@ function _ctools_export_unpack_object($schema, $data, $object = 'stdClass') {
*/
function ctools_export_unpack_object($table, $data) {
$schema = ctools_export_get_schema($table);
- return _ctools_export_unpack_object($schema, $data, $schema['export']['object']);
+ if (isset($schema['export']['object class callback'])) {
+ $function = $schema['export']['object class callback'];
+ $class = $function($data);
+ }
+ else {
+ $class = $schema['export']['object'];
+ }
+ return _ctools_export_unpack_object($schema, $data, $class);
}
/**