Enrich result of inquiry/form with additional meta information.

@param array $data An array to enrich with client, meta, ... information

@return array Enriched data
505624
public function enrichWithMetaInformation(array $data)
    {
        $data['ip']        = (true === isset($_SERVER['REMOTE_ADDR'])) ? $_SERVER['REMOTE_ADDR'] : null;
        $data['useragent'] = (true === isset($_SERVER['HTTP_USER_AGENT'])) ? $_SERVER['HTTP_USER_AGENT'] : null;
        $data['timestamp'] = time();

        return $data;
    }
146679
public function add(array $data)
    {
        $result = null;
        $this->hook->attach('product.add.before', $data, $result, $this);

        if (isset($result)) {
            return (int) $result;
        }

        $data['created'] = $data['modified'] = GC_TIME;
        $data += array('currency' => $this->config->get('currency', 'USD'));

        $this->setPrice($data);

        $result = $data['product_id'] = $this->db->insert('product', $data);

        $this->setTranslations($data, $this->translation_entity, 'product', false);
        $this->setImages($data, $this->file, 'product');

        $this->setSku($data, false);
        $this->setSkuCombinations($data, false);
        $this->setOptions($data, false);
        $this->setAttributes($data, false);
        $this->setAlias($data, $this->alias, 'product', false);
        $this->setRelated($data, false);

        $this->search->index('product', $data);
        $this->hook->attach('product.add.after', $data, $result, $this);
        return (int) $result;
    }
464437
public function populate($data = array())
    {
        foreach (array('title', 'meta_keywords', 'meta_description', 'content', 'heading', 'category') as $attr) {
            if (isset($data[$attr]) && $data[$attr]!= null) {
                $this->$attr = $data[$attr];
            }
        }
        foreach (array('active', 'sort_order', 'pushHome', 'displayHome') as $attr) {
            if (isset($data[$attr])) {
                $this->$attr = (bool) $data[$attr];
            }
        }
        if (isset($data['category']) && $data['category']!= null) {
            $this->category = (int) $data['category'];
        }
    }
895268
public function createRestrictions(array $data)
    {
        return array_map(
            function ($restriction) {
                if ($restriction instanceof Restriction) {
                    return $restriction;
                }

                if (!is_array($restriction)) {
                    throw new DomainException('Incorrect restriction - it must be an array or instance of Restriction.');
                }

                return Restriction::createFromData($restriction);
            },
            $data
        );
    }
227168
public function fill(array $data)
    {
        foreach ($data as $key => &$row) {
            $this->original = $value = Arr::get($row, $this->name);

            $value = $this->htmlEntityEncode($value);

            Arr::set($row, $this->name, $value);

            if ($this->isDefinedColumn()) {
                $this->useDefinedColumn();
            }

            if ($this->hasDisplayCallbacks()) {
                $value = $this->callDisplayCallbacks($this->original, $key);
                Arr::set($row, $this->name, $value);
            }
        }

        return $data;
    }
982240
protected function asArray($data = []): array
    {
        if ($data instanceof Collection) {
            $data = $data->all();
        } elseif ($data instanceof Arrayable) {
            $data = $data->toArray();
        }

        return $data;
    }
547260
protected function decorateFieldData(array $data)
    {
        // Get the key-reference pairs required to fill the drop-down

        $referenceData = $this->getReferenceDataProvider()->getForModelClassByType(
            get_class($this->model),
            'form.field',
            $this->field->key()
        );

        if ($referenceData) {
            $references = $this->getReferenceRepository()->getReferencesForModelMetaReference($referenceData)->all();
        } else {
            $references = [];
        }

        $data['dropdownOptions'] = $references;

        return $data;
    }
1349524
protected function expandToHandler($data)/*# : array */
    {
        if (is_callable($data)) {
            $result = [$data];
        } elseif (is_string($data)) {
            $result = [$data];
        } elseif ($this->hasPriority($data)) {
            $result = [$data];
        } else {
            $result = $data;
        }
        return (array) $result;
    }
921049
public function toObject(array $data)
    {
        $data = json_decode(json_encode($data));

        if ($data === []) {
            $data = new \StdClass();
        }

        return $data;
    }
1188477
protected function getResultAdded(array $data)
    {
        $options = array(
            'user_id' => $data['user_id'],
            'store_id' => $data['store_id']
        );

        $href = $this->url->get('wishlist');
        $existing = $this->wishlist->getList($options);

        return array(
            'redirect' => '',
            'severity' => 'success',
            'quantity' => count($existing),
            'wishlist_id' => $data['wishlist_id'],
            'message' => $this->translation->text('Product has been added to your <a href="@url">wishlist</a>', array(
                '@url' => $href)));
    }
292808
public function convertExtensionFeatures(array $data = null)
    {
        $features = [];
        $extendedFeatures = array_filter(array_filter((array) $data, 'is_array'), function ($item) { return !empty($item); });

        foreach ($extendedFeatures as $extendedFeature) {

            $feature = new ExtensionFeature();
            $feature->setId((string) $extendedFeature[JSONConstants::JSON_FEATURE_ID]);
            $feature->setUrl((string) $extendedFeature[JSONConstants::JSON_FEATURE_URL]);
            $feature->setCommonName((string) $extendedFeature[JSONConstants::JSON_FEATURE_COMMON_NAME]);
            $feature->setVersionLabel((string) $extendedFeature[JSONConstants::JSON_FEATURE_VERSION_LABEL]);
            $feature->setDescription((string) $extendedFeature[JSONConstants::JSON_FEATURE_DESCRIPTION]);

            $featureData = [];
            foreach ($extendedFeature[JSONConstants::JSON_FEATURE_DATA] ?? [] as $key => $value) {
                $featureData[$key] = $value;
            }

            $feature->setFeatureData($featureData);

            $feature->setExtensions($this->convertExtension($extendedFeature, JSONConstants::getFeatureKeys()));

            $features[] = $feature;
        }

        return $features;
    }
885351
public function expandData(array $data)
    {
        $fields = $this->schema->getFields();
        $table = $this->schema->getName();

        foreach ($fields as $field) {
            $name = $table . '_' . $field['name'];

            //if there's no data
            //or already is an array
            //or not a JSON type
            if (!isset($data[$name])
                || is_array($data[$name])
                || !in_array(
                    $field['field']['type'],
                    [
                        'multiselect',
                        'checkboxes',
                        'filelist',
                        'imagelist',
                        'tag',
                        'textlist',
                        'textarealist',
                        'wysiwyglist',
                        'meta',
                        'multirange',
                        'rawjson',
                        'fieldset',
                        'table',
                        'latlng'
                    ]
                )
            ) {
                //no need to expand
                continue;
            }

            $data[$name] = json_decode($data[$name], true);
        }

        return $data;
    }
869192
public function addMetadata($data)
    {
        if (is_array($data)) {
            foreach ($data as $k => $v) {
                $this->metadata[$k] = $v;
            }
        }
        else {
            $this->metadata[] = $data;
        }

        return $this;
    }
1164357
public function search(array $data)
    {
        if (!isset($data['size'])) {
            $data['size'] = 10;
        }

        $response = $this->client->post("{$this->uriSearch}search/", [
            'json' => $data,
            'query' => [
                'key' => $this->config['search']['key'],
            ],
        ]);

        $response = json_decode($response->getBody(), true);

        return $response;
    }
1129492
protected function enrichCustomData()
    {
        // Check filled fields and enrich them as required
        // Note that these can be either attributes or relations

        $fields = [];

        foreach ($this->info->show->fields as $key => $field) {

            try {
                $this->enrichField($key, $field, $fields);

            } catch (\Exception $e) {

                // Wrap and decorate exceptions so it is easier to track the problem source
                throw (new ModelInformationEnrichmentException(
                    "Issue with show field '{$key}' (show.fields.{$key}): \n{$e->getMessage()}",
                    $e->getCode(),
                    $e
                ))
                    ->setSection('show.fields')
                    ->setKey($key);
            }
        }

        $this->info->show->fields = $fields;
    }
880913
public function add(array $data)
    {
        $result = null;
        $this->hook->attach('file.add.before', $data, $result, $this);

        if (isset($result)) {
            return (int) $result;
        }

        if (empty($data['mime_type'])) {
            $data['mime_type'] = mime_content_type(gplcart_file_absolute($data['path']));
        }

        if (empty($data['file_type'])) {
            $data['file_type'] = strtolower(strtok($data['mime_type'], '/'));
        }

        if (empty($data['title'])) {
            $data['title'] = basename($data['path']);
        }

        $data['created'] = $data['modified'] = GC_TIME;
        $result = $data['file_id'] = $this->db->insert('file', $data);

        $this->setTranslations($data, $this->translation_entity, 'file', false);

        $this->hook->attach('file.add.after', $data, $result, $this);
        return (int) $result;
    }
520425
public function loadInfo($data)
    {
        if ($this->isJson($data)) {
            $data = \Zend_Json_Decoder::decode($data);
        } elseif (is_null($data)) {
            $data = [];
        }

        $this->addData($data);

        return $this;
    }