diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php index d77a2e7..e5cff87 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php @@ -554,42 +554,49 @@ protected function defineOptions() { 'type' => array('default' => 'none'), 'options' => array('default' => array()), ), + 'merge_defaults' => 'mergePlugin', ), 'cache' => array( 'contains' => array( 'type' => array('default' => 'none'), 'options' => array('default' => array()), ), + 'merge_defaults' => 'mergePlugin', ), 'query' => array( 'contains' => array( 'type' => array('default' => 'views_query'), 'options' => array('default' => array()), ), + 'merge_defaults' => 'mergePlugin', ), 'exposed_form' => array( 'contains' => array( 'type' => array('default' => 'basic'), 'options' => array('default' => array()), ), + 'merge_defaults' => 'mergePlugin', ), 'pager' => array( 'contains' => array( 'type' => array('default' => 'mini'), 'options' => array('default' => array()), ), + 'merge_defaults' => 'mergePlugin', ), 'style' => array( 'contains' => array( 'type' => array('default' => 'default'), 'options' => array('default' => array()), ), + 'merge_defaults' => 'mergePlugin', ), 'row' => array( 'contains' => array( 'type' => array('default' => 'fields'), 'options' => array('default' => array()), ), + 'merge_defaults' => 'mergePlugin', ), 'exposed_block' => array( @@ -598,27 +605,34 @@ protected function defineOptions() { 'header' => array( 'default' => array(), + 'merge_defaults' => 'mergeHandler', ), 'footer' => array( 'default' => array(), + 'merge_defaults' => 'mergeHandler', ), 'empty' => array( 'default' => array(), + 'merge_defaults' => 'mergeHandler', ), // We want these to export last. // These are the 5 handler types. 'relationships' => array( 'default' => array(), + 'merge_defaults' => 'mergeHandler', ), 'fields' => array( 'default' => array(), + 'merge_defaults' => 'mergeHandler', ), 'sorts' => array( 'default' => array(), + 'merge_defaults' => 'mergeHandler', ), 'arguments' => array( 'default' => array(), + 'merge_defaults' => 'mergeHandler', ), 'filter_groups' => array( 'contains' => array( @@ -2729,11 +2743,15 @@ public function getPagerText() { * Merges default values for all plugin types. */ public function mergeDefaults() { - foreach (array('access', 'cache', 'query', 'exposed_form', 'pager', 'style', 'row') as $type) { - if (($this->isDefaultDisplay() || !$this->isDefaulted($type)) && isset($this->display['display_options'][$type])) { - $plugin = $this->getPlugin($type); - $this->display['display_options'][$type]['options'] += $plugin->options; + $defined_options = $this->defineOptions(); + + // Find all defined options, that have specified a merge_defaults callback. + foreach ($defined_options as $name => $definition) { + if (!isset($definition['merge_defaults']) || !method_exists($this, $definition['merge_defaults'])) { + continue; } + + $this->{$definition['merge_defaults']}($name); } $types = ViewExecutable::viewsHandlerTypes(); @@ -2749,6 +2767,35 @@ public function mergeDefaults() { } } + /** + * Merges plugins default values. + * + * @param string $name + * The name of the option. + */ + protected function mergePlugin($name) { + if (($this->isDefaultDisplay() || !$this->isDefaulted($name)) && isset($this->display['display_options'][$type])) { + $plugin = $this->getPlugin($type); + $this->display['display_options'][$type]['options'] += $plugin->options; + } + } + + /** + * Merges handlers default values. + * + * @param string $name + * The name of the option. + */ + protected function mergeHandler($name) { + $types = ViewExecutable::viewsHandlerTypes(); + + foreach ($this->getHandlers($name) as $id => $handler) { + if (isset($this->display['display_options'][$name][$id])) { + $this->display['display_options'][$types[$name]['plural']][$id] += $handler->options; + } + } + } + } /**