function views_data_export_migration_convert in Views data export 6.2
Same name and namespace in other branches
- 6.3 migration/views_data_export_migration.module \views_data_export_migration_convert()
- 6 migration/views_data_export_migration.module \views_data_export_migration_convert()
Converts all views_bonus_export displays on the given view to views_data_export displays and returns the new view
Parameters
$view: The view object to migrate
$displays: An array of displays to migrate, or a single display_id to migrate. If nothing is provided here, all migratable displays will be migrated.
$options: There are some options that views_data_export displays have that feed displays do not, provide here the values desired in the migrated version. The defaults are: 'use_batch' => 1
1 call to views_data_export_migration_convert()
File
- migration/
views_data_export_migration.module, line 187 - Provides helpers and UI (admin/build/views/tools/views-data-export-migration) for migrating views_bonus_export views to views_data_export.
Code
function views_data_export_migration_convert($view_to_export, $displays = NULL, $options = array()) {
// Get all migratable displays for our view
$_all_migratable_displays = _views_data_export_migratable_displays($view_to_export);
// Find views_bonus_export displays we want to export
if (!isset($display)) {
$displays = $_all_migratable_displays;
}
if (isset($displays) && !is_array($displays)) {
$displays = array(
$displays,
);
}
// Ensure displays passed to this function are indeed suitable for migration
$displays = array_intersect($_all_migratable_displays, $displays);
if (empty($displays)) {
drupal_set_message(t('There are no displays on this view suitable for migration.'), 'error');
return FALSE;
}
// Make sure we have a clean copy of the view
$view = $view_to_export
->clone_view();
foreach ($displays as $d) {
// Change display views_data_export display
$view->display[$d]->display_plugin = 'views_data_export';
// We may have had to work out what to do if the display was
// inheriting its options from the default
// But at the moment it is impossible to make the default
// display have any of views_bonus_export's style plugins, so they
// will never be inherited from the default display
//Change the style plugin to our one
$view->display[$d]->display_options['style_plugin'] = _views_data_export_migration_style_plugin_mappings($view->display[$d]->display_options['style_plugin']);
// Set any display options we wanted to add/override
foreach ($options as $opname => $opval) {
$view->display[$d]->display_options[$opname] = $opval;
}
}
return $view;
}