1 base.inc views_object::unpack_options(&$storage, $options, $definition = NULL, $all = TRUE, $check = TRUE)

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

File

core/modules/views/includes/base.inc, line 95
Provides the basic object definitions used by plugins and handlers.

Class

views_object
Basic definition for many views objects.

Code

function unpack_options(&$storage, $options, $definition = NULL, $all = TRUE, $check = TRUE) {
  if ($check && !is_array($options)) {
    return;
  }

  if (!isset($definition)) {
    $definition = $this->option_definition();
  }

  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->unpack_options($storage[$key], $value, isset($definition[$key]['contains']) ? $definition[$key]['contains'] : array(), $all, FALSE);
    }
    elseif ($all || !empty($definition[$key])) {
      $storage[$key] = $value;
    }
  }
}