protected function WizardPluginBase::setDefaultOptions

Sets options for a display and makes them the default options if possible.

This function can be used to set options for a display when it is desired that the options also become the defaults for the view whenever possible. This should be done for the "primary" display created in the view wizard, so that new displays which the user adds later will be similar to this one.

Parameters

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

Drupal\views\View\plugin\display\DisplayPluginBase $display: The display handler which the options will be applied to. The default display will actually be assigned the options (and this display will inherit them) when possible.

Drupal\views\View\plugin\display\DisplayPluginBase $default_display: The default display handler, which will store the options when possible.

1 call to WizardPluginBase::setDefaultOptions()
WizardPluginBase::addDisplays in drupal/core/modules/views/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php
Adds the array of display options to the view, with appropriate overrides.

File

drupal/core/modules/views/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php, line 1050
Definition of Drupal\views\Plugin\views\wizard\WizardPluginBase.

Class

WizardPluginBase
Provides the interface and base class for Views Wizard plugins.

Namespace

Drupal\views\Plugin\views\wizard

Code

protected function setDefaultOptions($options, DisplayPluginBase $display, DisplayPluginBase $default_display) {
  foreach ($options as $option => $value) {

    // If the default display supports this option, set the value there.
    // Otherwise, set it on the provided display.
    $default_value = $default_display
      ->getOption($option);
    if (isset($default_value)) {
      $default_display
        ->setOption($option, $value);
    }
    else {
      $display
        ->setOption($option, $value);
    }
  }
}