public function PluginBase::unpackOptions

Unpack options over our existing defaults, drilling down into arrays so that defaults don't get totally blown away.

11 calls to PluginBase::unpackOptions()
AccessPluginBase::init in drupal/core/modules/views/lib/Drupal/views/Plugin/views/access/AccessPluginBase.php
Initialize the plugin.
ArgumentDefaultPluginBase::init in drupal/core/modules/views/lib/Drupal/views/Plugin/views/argument_default/ArgumentDefaultPluginBase.php
Initialize this plugin with the view and the argument it is linked to.
ArgumentValidatorPluginBase::init in drupal/core/modules/views/lib/Drupal/views/Plugin/views/argument_validator/ArgumentValidatorPluginBase.php
Initialize this plugin with the view and the argument it is linked to.
CachePluginBase::init in drupal/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php
Initialize the plugin.
DisplayPluginBase::init in drupal/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php

... See full list

File

drupal/core/modules/views/lib/Drupal/views/Plugin/views/PluginBase.php, line 101
Definition of Drupal\views\Plugin\views\PluginBase.

Class

PluginBase

Namespace

Drupal\views\Plugin\views

Code

public function unpackOptions(&$storage, $options, $definition = NULL, $all = TRUE, $check = TRUE) {
  if ($check && !is_array($options)) {
    return;
  }
  if (!isset($definition)) {
    $definition = $this
      ->defineOptions();
  }
  foreach ($options as $key => $value) {
    if (is_array($value)) {

      // Ignore arrays with no definition.
      if (!$all && empty($definition[$key])) {
        continue;
      }
      if (!isset($storage[$key]) || !is_array($storage[$key])) {
        $storage[$key] = array();
      }

      // If we're just unpacking our known options, and we're dropping an
      // unknown array (as might happen for a dependent plugin fields) go
      // ahead and drop that in.
      if (!$all && isset($definition[$key]) && !isset($definition[$key]['contains'])) {
        $storage[$key] = $value;
        continue;
      }
      $this
        ->unpackOptions($storage[$key], $value, isset($definition[$key]['contains']) ? $definition[$key]['contains'] : array(), $all, FALSE);
    }
    else {
      if ($all || !empty($definition[$key])) {
        $storage[$key] = $value;
      }
    }
  }
}