You are here

protected function PluginBase::setOptionDefaults in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/views/src/Plugin/views/PluginBase.php \Drupal\views\Plugin\views\PluginBase::setOptionDefaults()

Fills up the options of the plugin with defaults.

Parameters

array $storage: An array which stores the actual option values of the plugin.

array $options: An array which describes the options of a plugin. Each element is an associative array containing:

  • default: The default value of one option. Should be translated to the interface text language selected for page if translatable.
  • (optional) contains: An array which describes the available options under the key. If contains is set, the default will be ignored and assumed to be an empty array.
  • (optional) 'bool': TRUE if the value is boolean, else FALSE.
3 calls to PluginBase::setOptionDefaults()
DisplayPluginBase::initDisplay in core/modules/views/src/Plugin/views/display/DisplayPluginBase.php
Initializes the display plugin.
PluginBase::init in core/modules/views/src/Plugin/views/PluginBase.php
Initialize the plugin.
TestHelperPlugin::testSetOptionDefaults in core/modules/views/src/Tests/TestHelperPlugin.php
Calls the protected method setOptionDefaults().

File

core/modules/views/src/Plugin/views/PluginBase.php, line 180
Contains \Drupal\views\Plugin\views\PluginBase.

Class

PluginBase
Base class for any views plugin types.

Namespace

Drupal\views\Plugin\views

Code

protected function setOptionDefaults(array &$storage, array $options) {
  foreach ($options as $option => $definition) {
    if (isset($definition['contains'])) {
      $storage[$option] = array();
      $this
        ->setOptionDefaults($storage[$option], $definition['contains']);
    }
    else {
      $storage[$option] = $definition['default'];
    }
  }
}