Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. PluginBase.php

function 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.
2 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.

File

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

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] = [];
            $this->setOptionDefaults($storage[$option], $definition['contains']);
        }
        else {
            $storage[$option] = $definition['default'];
        }
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal