Load all of the values in an associative array. Ignores all fields
not in the model.

@param   array    $values  field => value pairs
@param   boolean  $clean   values are clean (from database)?
@return  Mongo_Document
433440
public function load_values(array $values, $clean = FALSE)
  {
    if($clean === TRUE)
    {
      $this->before_load();

      $this->_object = $values;
      $this->_loaded = ! empty($this->_object);

      $this->after_load();
    }
    else
    {
      foreach ($values as $field => $value)
      {
        $this->__set($field, $value);
      }
    }

    return $this;
  }
891366
private function filterValues(array $values)
    {
        foreach ($values as $i => $field) {
            if (is_bool($field)) {
                $values[$i] = (int) $field;
            } elseif ($field instanceof \DateTime) {
                $values[$i] = $field->format('Y-m-d H:i:s');
            } elseif (!is_scalar($field)) {
                unset($values[$i]);
            }
        }
        return $values;
    }
579575
public function merge(array $values)
    {
        $storage = $this->getArrayCopy();
        $storage = array_merge($storage, $values);

        $this->exchangeArray($storage);

        return $storage;
    }
710283
public function values($values)
    {
        if ($values instanceof Collection) {
            $values = $values->toArray();
        }

        $this->values = $values;

        return $this;
    }
970203
protected static function load(array $values)
    {
        $container = new static($values);

        $container['debugger'] = new Debugger();
        $container['grav'] = function (Container $container) {
            user_error('Calling $grav[\'grav\'] or {{ grav.grav }} is deprecated since Grav 1.6, just use $grav or {{ grav }}', E_USER_DEPRECATED);

            return $container;
        };

        $container->measureTime('_services', 'Services', function () use ($container) {
            $container->registerServices();
        });

        return $container;
    }
238072
public function setFieldValues(array $values)
    {
        $fields = $this->toArray();
        foreach ($fields as $name => $value) {
            if (isset($values[$name]) && (!($this->getField($name) instanceof Element\Button) &&
                !($this->getField($name) instanceof Element\Input\Button) &&
                !($this->getField($name) instanceof Element\Input\Submit) &&
                !($this->getField($name) instanceof Element\Input\Reset))) {
                $this->setFieldValue($name, $values[$name]);
            } else if (!($this->getField($name) instanceof Element\Button) &&
                !($this->getField($name) instanceof Element\Input\Button) &&
                !($this->getField($name) instanceof Element\Input\Submit) &&
                !($this->getField($name) instanceof Element\Input\Reset)) {
                $this->getField($name)->resetValue();
            }
        }
        $this->filterValues();
        return $this;
    }
944093
public function getSanitizedValues(&$values = [])
    {
        array_walk($this->fields, function ($field, $index) use (&$values) {
            if (is_array($field)) {
                return $this->sanitizeConditionalValues($values, $field, $index);
            }

            return $this->sanitizeValues($values[$field->getSlug()], $field);
        });

        return $values;
    }
579896
public static function createFromValues(array $values)
    {
        if (\array_key_exists('keys', $values) && \is_array($values['keys'])) {
            return JWKSet::createFromKeyData($values);
        }

        return JWK::create($values);
    }
559729
static function fromArray($values)
    {
        if ($values === null) {
            return null;
        }

        ksort($values);

        $serialized = '';
        foreach ($values as $key => $value) {
            if (is_array($value)) {
                list($key, $value) = array($value[0], $value[1]);
            }

            if (strpos($key, ':') !== false) {
                return null;
            }

            if (strpos($key, "\n") !== false) {
                return null;
            }

            if (strpos($value, "\n") !== false) {
                return null;
            }
            $serialized .= "$key:$value\n";
        }
        return $serialized;
    }
868756
function values(array $values)
    {
        $cols = array();
        $vals = array();

        foreach ($values as $col => $val) {
            if (null !== $val) {
                $cols[] = $col;
                $vals[] = $val;
            }
        }

        foreach ($cols as &$col) {
            $this->nodes->columns[] = new UnqualifiedColumn($col);
        }

        $this->nodes->values = array_merge($this->nodes->values, $vals);
        return $this;
    }
890369
public function setValue($values = [])
    {
        $this->initializeElements();

        foreach ($this->getElements() as $element) {
            $element->setValue(false);
        }

        if ($values instanceof Collection) {
            foreach ($values as $value) {
                $id = $value->getId();
                $this->getElement($id)->setValue(true);
            }
        } else {
            foreach ((array)$values as $key => $value) {
                $this->getElement($key)->setValue(true);
            }
        }

        return $this;
    }
374566
public function setFieldValues(array $values)
    {
        foreach ($values as $name => $value) {
            $this->setFieldValue($name, $value);
        }
        return $this;
    }
422313
public function intoValues(array $values)
    {
        if (is_array($values[0])) {
            $this->intoValues = $values;
        } else {
            $this->intoValues[] = $values;
        }
        return $this;
    }
1123897
public function load(array $data, $purge = false)
    {
        // has pending
        if ($this->mongator->getUnitOfWork()->hasPending()) {
            throw new \RuntimeException('The Mongator\'s Unit of Work has pending operations.');
        }

        // purge
        if ($purge) {
            foreach ($this->mongator->getAllRepositories() as $repository) {
                $repository->getCollection()->drop();
            }
        }

        // vars
        $mongator = $this->mongator;
        $documents = array();

        $maps = array();
        foreach ($data as $class => $datum) {
            $maps[$class] = $mongator->getRepository($class)->getMetadata();
        }

        $referencesOne = array();
        $referencesMany = array();
        foreach ($maps as $class => $metadata) {
            $referencesOne[$class] = $metadata['referencesOne'];
            $referencesMany[$class] = $metadata['referencesMany'];

            $map = $metadata;
            while ($map['inheritance']) {
                $inheritanceClass = $map['inheritance']['class'];
                $map = $mongator->getRepository($inheritanceClass)->getMetadata();
                $referencesOne[$class] = array_merge($map['referencesOne'], $referencesOne[$class]);
                $referencesMany[$class] = array_merge($map['referencesMany'], $referencesMany[$class]);
            }
        }

        // process function
        $process = function ($class, $key) use (&$process, $mongator, &$data, &$documents, &$maps, &$referencesOne, &$referencesMany) {
            static $processed = array();

            if (isset($processed[$class][$key])) {
                return;
            }

            if (!isset($data[$class][$key])) {
                throw new \RuntimeException(sprintf('The document "%s" of the class "%s" does not exist.', $key, $class));
            }
            $datum = $data[$class][$key];

            $documents[$class][$key] = $document = new $class($mongator);

            // referencesOne
            foreach ($referencesOne[$class] as $name => $reference) {
                if (!isset($datum[$name])) {
                    continue;
                }

                $process($reference['class'], $datum[$name]);

                if (!isset($documents[$reference['class']][$datum[$name]])) {
                    throw new \RuntimeException(sprintf('The reference "%s" (%s) for the class "%s" does not exists.', $datum[$name], $name, $class));
                }
                $document->set($name, $documents[$reference['class']][$datum[$name]]);
                unset($datum[$name]);
            }

            // referencesMany
            foreach ($referencesMany[$class] as $name => $reference) {
                if (!isset($datum[$name])) {
                    continue;
                }

                $refs = array();
                foreach ($datum[$name] as $value) {
                    $process($reference['class'], $value);

                    if (!isset($documents[$reference['class']][$value])) {
                        throw new \RuntimeException(sprintf('The reference "%s" (%s) for the class "%s" does not exists.', $value, $name, $class));
                    }
                    $refs[] = $documents[$reference['class']][$value];
                }
                $document->get($name)->add($refs);
                unset($datum[$name]);
            }

            // document
            $document->fromArray($datum);
            $mongator->persist($document);

            $processed[$class][$key] = true;
            unset($data[$class][$key]);
        };

        // process
        foreach ($data as $class => $datum) {
            foreach ($datum as $key => $value) {
                $process($class, $key);
            }
        }

        // flush
        $this->mongator->flush();
    }
13210
protected function reload_from_record($record, $clean = false) {
        $this->id           = $record->id;
        $this->tourid       = $record->tourid;
        if ($clean) {
            $this->title    = clean_param($record->title, PARAM_TEXT);
            $this->content  = clean_text($record->content);
        } else {
            $this->title    = $record->title;
            $this->content  = $record->content;
        }
        $this->targettype   = $record->targettype;
        $this->targetvalue  = $record->targetvalue;
        $this->sortorder    = $record->sortorder;
        $this->config       = json_decode($record->configdata);
        $this->dirty        = false;

        return $this;
    }
4252
public function groupQueryValues(array $values)
    {
        $joined = Resources::EMPTY_STRING;

        foreach ($values as $value) {
            if (!is_null($value) && !empty($value)) {
                $joined .= $value.Resources::SEPARATOR;
            }
        }

        return trim($joined, Resources::SEPARATOR);
    }
944967
public function filterByIds(array $values): self
    {
        $fieldPath = Item::getPathByField('id');
        if (!empty($values)) {
            $this->filters['id'] = Filter::create(
                $fieldPath,
                $values,
                Filter::AT_LEAST_ONE,
                Filter::TYPE_FIELD
            );
        } else {
            unset($this->filters['id']);
        }

        return $this;
    }