You are here

function services_views_clone_display in Services Views 7

3 calls to services_views_clone_display()
ServicesViewsSecurityUpgradePathTest::testClone in tests/services_views_upgrade_path.test
Test the upgraded clone to see if it produces the same output.
ServicesViewsSecurityUpgradePathTest::testCloneDefault in tests/services_views_upgrade_path.test
Test cloning the default display.
services_views_convert_white_list_to_clones in ./services_views.module

File

./services_views.module, line 624
Provides a generic but powerful API for web services.

Code

function services_views_clone_display($view, $display_name) {
  $display = $view->display[$display_name];
  $display_names = array_keys($view->display);
  $new_display_name = substr('services_clone_' . $display_name, 0, 62);
  $count = 0;
  while (in_array($new_display_name, $display_names)) {
    $new_display_name = substr('services_clone_' . $display_name, 0, 62) . '_' . ++$count;
  }
  $view
    ->add_display('services', "Services Clone of " . $display->display_title, $new_display_name);
  $new_display = $view->display[$new_display_name];
  $new_display->display_options = $display->display_options;
  $new_display->display_options['path'] = $view->name . '/' . $display_name;
  $view
    ->save();
  return $new_display_name;
}