1 views_ui_base_views_wizard.php protected ViewsUiBaseViewsWizard::set_override_options($options, $display, $default_display)

Sets options for a display, inheriting from the defaults when possible.

This function can be used to set options for a display when it is desired that the options inherit from the default display whenever possible. This avoids setting too many options as overrides, which will be harder for the user to modify later. For example, if $this->set_default_options() was previously called on a page display and then this function is called on a block display, and if the user entered the same title for both displays in the views wizard, then the view will wind up with the title stored as the default (with the page and block both inheriting from it).

Parameters

$options: An array whose keys are the name of each option and whose values are the desired values.

$display: The display which the options will apply to. It will get the options by inheritance from the default display when possible.

$default_display: The default display, from which the options will be inherited when possible.

File

core/modules/views_ui/wizards/views_ui_base_views_wizard.php, line 893
Provides the interface and base class for Views Wizard plugins.

Class

ViewsUiBaseViewsWizard
A very generic Views Wizard class - can be constructed for any base table.

Code

protected function set_override_options($options, $display, $default_display) {
  foreach ($options as $option => $value) {
    // Only override the default value if it is different from the value that
    // was provided.
    $default_value = $default_display->get_option($option);
    if (!isset($default_value)) {
      $display->set_option($option, $value);
    }
    elseif ($default_value !== $value) {
      $display->override_option($option, $value);
    }
  }
}