function ViewsUiBaseViewsWizard::set_override_options

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

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

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

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

1 call to ViewsUiBaseViewsWizard::set_override_options()
ViewsUiBaseViewsWizard::add_displays in plugins/views_wizard/views_ui_base_views_wizard.class.php
Add the array of display options to the view, with appropriate overrides.

File

plugins/views_wizard/views_ui_base_views_wizard.class.php, line 917

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);
        }
    }
}