You are here

protected function PluginBase::setOptionDefaults in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/views/src/Plugin/views/PluginBase.php \Drupal\views\Plugin\views\PluginBase::setOptionDefaults()
  2. 9 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.

File

core/modules/views/src/Plugin/views/PluginBase.php, line 177

Class

PluginBase

Namespace

Drupal\views\Plugin\views

Code

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