function DisplayPluginBase::mergeDefaults

Same name in other branches
  1. 8.9.x core/modules/views/src/Plugin/views/display/DisplayPluginBase.php \Drupal\views\Plugin\views\display\DisplayPluginBase::mergeDefaults()
  2. 10 core/modules/views/src/Plugin/views/display/DisplayPluginBase.php \Drupal\views\Plugin\views\display\DisplayPluginBase::mergeDefaults()
  3. 11.x core/modules/views/src/Plugin/views/display/DisplayPluginBase.php \Drupal\views\Plugin\views\display\DisplayPluginBase::mergeDefaults()

Overrides DisplayPluginInterface::mergeDefaults

File

core/modules/views/src/Plugin/views/display/DisplayPluginBase.php, line 2666

Class

DisplayPluginBase
Base class for views display plugins.

Namespace

Drupal\views\Plugin\views\display

Code

public function mergeDefaults() {
    $defined_options = $this->defineOptions();
    // Build a map of plural => singular for handler types.
    $type_map = [];
    foreach (ViewExecutable::getHandlerTypes() as $type => $info) {
        $type_map[$info['plural']] = $type;
    }
    // Find all defined options, that have specified a merge_defaults callback.
    foreach ($defined_options as $type => $definition) {
        if (!isset($definition['merge_defaults']) || !is_callable($definition['merge_defaults'])) {
            continue;
        }
        // Switch the type to singular, if it's a plural handler.
        if (isset($type_map[$type])) {
            $type = $type_map[$type];
        }
        call_user_func($definition['merge_defaults'], $type);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.