1 view.inc view::save()

Save the view to a configuration file.

File

core/modules/views/includes/view.inc, line 1793
Provides the view object type and associated methods.

Class

view

Code

function save() {
  $config_data = array(
    'name' => $this->name,
    'description' => $this->description,
  );
  // Storage settings are only saved if this view was provided by a module.
  // Otherwise VIEWS_STORAGE_NORMAL is assumed on load.
  if ($this->module) {
    $config_data['module'] = $this->module;
    $config_data['storage'] = VIEWS_STORAGE_OVERRIDE;
  }
  $config_data += array(
    'tag' => $this->tag,
    'disabled' => (boolean) $this->disabled,
    'base_table' => $this->base_table,
    'human_name' => $this->human_name,
    'core' => $this->core,
    'display' => array(),
  );
  foreach ($this->display as $display) {
    $display_config_data = array(
      'display_title' => $display->display_title,
      'display_plugin' => $display->display_plugin,
      'display_options' => $display->display_options,
    );
    $config_data['display'][$display->id] = $display_config_data;
  }
  // Ensure we don't include the lock information in the saved config.
  if (property_exists($this, 'locked')) {
    unset($this->locked);
  }
  config('views.view.' . $this->name)->setData($config_data)->save();
  $this->save_locale_strings();

  // Clear caches.
  views_invalidate_cache();
}