protected function PluginBase::setOptionDefaults in Drupal 9
Same name and namespace in other branches
- 8 core/modules/views/src/Plugin/views/PluginBase.php \Drupal\views\Plugin\views\PluginBase::setOptionDefaults()
- 10 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 178
Class
- PluginBase
- Base class for any views plugin types.
Namespace
Drupal\views\Plugin\viewsCode
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'];
}
}
}