Created
April 8, 2015 08:14
-
-
Save damiankloip/78a26ae976e721b9054e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/core/modules/views/src/Plugin/views/HandlerBase.php b/core/modules/views/src/Plugin/views/HandlerBase.php | |
index b10b948..78cd431 100644 | |
--- a/core/modules/views/src/Plugin/views/HandlerBase.php | |
+++ b/core/modules/views/src/Plugin/views/HandlerBase.php | |
@@ -133,7 +133,7 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o | |
$options['field'] = $this->actualField; | |
} | |
- $this->unpackOptions($this->options, $options); | |
+ $this->doUnpackOptions($options); | |
// This exist on most handlers, but not all. So they are still optional. | |
if (isset($options['table'])) { | |
@@ -824,7 +824,7 @@ public function submitTemporaryForm($form, FormStateInterface $form_state) { | |
// This unpacks only options that are in the definition, ensuring random | |
// extra stuff on the form is not sent through. | |
- $handler->unpackOptions($handler->options, $options, NULL, FALSE); | |
+ $handler->doUnpackOptions($options, FALSE); | |
// Store the item back on the view. | |
$executable = $view->getExecutable(); | |
diff --git a/core/modules/views/src/Plugin/views/PluginBase.php b/core/modules/views/src/Plugin/views/PluginBase.php | |
index 9c0f49b..41c6756 100644 | |
--- a/core/modules/views/src/Plugin/views/PluginBase.php | |
+++ b/core/modules/views/src/Plugin/views/PluginBase.php | |
@@ -142,7 +142,16 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o | |
$this->setOptionDefaults($this->options, $this->defineOptions()); | |
$this->displayHandler = $display; | |
- $this->unpackOptions($this->options, $options); | |
+ $this->doUnpackOptions($options); | |
+ } | |
+ | |
+ /** | |
+ * @param array $options | |
+ * The options to unpack on this plugin. | |
+ * @param bool $all | |
+ */ | |
+ public function doUnpackOptions(array $options, $all = TRUE) { | |
+ $this->unpackOptions($this->options, $options, $this->defineOptions(), $all); | |
} | |
/** | |
@@ -219,15 +228,7 @@ protected function doFilterByDefinedOptions(array &$storage, array $options) { | |
/** | |
* {@inheritdoc} | |
*/ | |
- public function unpackOptions(&$storage, $options, $definition = NULL, $all = TRUE, $check = TRUE) { | |
- if ($check && !is_array($options)) { | |
- return; | |
- } | |
- | |
- if (!isset($definition)) { | |
- $definition = $this->defineOptions(); | |
- } | |
- | |
+ public function unpackOptions(&$storage, $options, $definition = NULL, $all = TRUE) { | |
foreach ($options as $key => $value) { | |
if (is_array($value)) { | |
// Ignore arrays with no definition. | |
@@ -247,7 +248,7 @@ public function unpackOptions(&$storage, $options, $definition = NULL, $all = TR | |
continue; | |
} | |
- $this->unpackOptions($storage[$key], $value, isset($definition[$key]['contains']) ? $definition[$key]['contains'] : array(), $all, FALSE); | |
+ $this->unpackOptions($storage[$key], $value, isset($definition[$key]['contains']) ? $definition[$key]['contains'] : [], $all); | |
} | |
else if ($all || !empty($definition[$key])) { | |
$storage[$key] = $value; | |
diff --git a/core/modules/views/src/Plugin/views/ViewsPluginInterface.php b/core/modules/views/src/Plugin/views/ViewsPluginInterface.php | |
index d36b4b2..0adb186 100644 | |
--- a/core/modules/views/src/Plugin/views/ViewsPluginInterface.php | |
+++ b/core/modules/views/src/Plugin/views/ViewsPluginInterface.php | |
@@ -171,7 +171,7 @@ public function query(); | |
* Unpack options over our existing defaults, drilling down into arrays | |
* so that defaults don't get totally blown away. | |
*/ | |
- public function unpackOptions(&$storage, $options, $definition = NULL, $all = TRUE, $check = TRUE); | |
+ public function unpackOptions(&$storage, $options, $definition, $all = TRUE); | |
/** | |
* Provide a form to edit options for this plugin. | |
diff --git a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php | |
index 290d1a7..e170ff0 100644 | |
--- a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php | |
+++ b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php | |
@@ -197,7 +197,7 @@ public function initDisplay(ViewExecutable $view, array &$display, array &$optio | |
$this->options = $cache->data; | |
} | |
else { | |
- $this->unpackOptions($this->options, $options); | |
+ $this->doUnpackOptions($options); | |
\Drupal::cache('data')->set($cid, $this->options, Cache::PERMANENT, $this->view->storage->getCacheTags()); | |
} | |
static::$unpackOptions[$cid] = $this->options; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment