Enriches field data before passing it on to the view.

@param array $data
@return array
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;
    }
935122
protected function decorateFieldData(array $data)
    {
        // Get the key-reference pairs required to fill the drop-down and group them by the model class.
        // Also get displayable labels for each model class.

        $modelClasses = $this->getMorphableModels();

        $modelLabels = [];
        $references  = [];

        foreach ($modelClasses as $modelClass) {

            $modelLabels[ $modelClass ] = $this->getModelDisplayLabel($modelClass);

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

            $references[$modelClass] = [];

            if ($referenceData) {
                foreach (
                    $this->getReferenceRepository()->getReferencesForModelMetaReference($referenceData)->all()
                    as $referenceKey => $reference
                ) {
                    $references[$modelClass][ $modelClass . static::CLASS_AND_KEY_SEPARATOR . $referenceKey] = $reference;
                }
            }
        }

        $data['modelLabels']     = $modelLabels;
        $data['dropdownOptions'] = $references;

        return $data;
    }
1329146
protected function fillObjects(array $data)
    {
        $result = [];
        foreach ($data as $item) {
            $result[] = (new static())->setAttributes($item);
        }
        return $result;
    }
635003
protected function toArrayRecursive($data)
    {

        if ($data instanceof RecordFieldValue) {
            return $data->toArrayRecursive($data);
        } else {
            return parent::toArrayRecursive($data);
        }
    }
1328323
public function filterData(array $data)
    {
        // Filter the sparse field-set if we have a specific list of properties
        // defined that we want.
        $filterProps = $this->filterProps();
        if (!empty($filterProps)) {
            $filteredData = array_filter($data, function ($key) use ($filterProps) {
                return \in_array($key, $filterProps, true);
            }, ARRAY_FILTER_USE_KEY);

            // We must always have some data after filtering, so if our filtered
            // data is empty, we should just ignore it ...
            if (!empty($filteredData)) {
                $data = $filteredData;
            }
        }

        return $data;
    }
1360250
protected function prepareRows(array $data)
    {
        $rows = [];

        foreach ($data as $date => $levels) {
            $rows[$date] = array_merge(compact('date'), $levels);
        }

        return $rows;
    }
272813
protected function prepareField(array $data)
    {
        return array_merge([

            /** Rendering config */
            'default' => null, // todo test null vs empty
            'position' => 0,

            /** Handler config */
            'flash' => true, // which fields to flash into session
            'validate' => [], // field validation rules

            /** HTML config */
            'label' => null, // html label
            'label_options' => [], // label options
            'comment' => null, // string comment

            /** Field config */
            'type' => 'text', // type alias
            'name' => null, // field name
            'value' => null, // field value
            'options' => ['id' => null], // field options
            'resource' => null,
            'use_default' => false,// bool|string, adds checkbox to disable field

        ], $data);
    }
565041
public function getTransformedData($data): array
    {
        if (method_exists($this, 'transform')) {
            // Transformer provides a 'transform' method
            return (array) $this->transform($data);
        }

        // Otherwise, use the withProps method which calls getProps()
        return $this->withProps($data, $this->getProps());
    }
364644
protected function attachAppends(array $data)
    {
        $appends = [];
        foreach ($this->appends as $key => $value) {
            if (is_callable($value)) {
                $appends[$key] = value($value($this->getFilteredQuery()));
            } else {
                $appends[$key] = $value;
            }
        }

        return array_merge($data, $appends);
    }
261923
private function asData(array $data)
    {
        foreach ($data as $key => $value) {
            if ($value instanceof RawSqlFragmentInterface) {
                $data[$key] = $value->getFragment();
            } elseif ($value instanceof RawBindingInterface) {
                $data[$key] = $value->getTarget();
            } else {
                $placeholder = $this->getUniqPlaceholder();

                $data[$key] = $placeholder;
                $this->bind($placeholder, $value);
            }
        }

        return $data;
    }
717726
private function cleanFeatureData($data)
    {
        $fields = array_merge($this->getFields(), array($this->getUniqueId(), $this->getGeomField()));

        // clean data from feature
        foreach ($data as $fieldName => $value) {
            if (isset($fields[ $fieldName ])) {
                unset($data[ $fieldName ]);
            }
        }
        return $data;
    }
1059762
protected function normalizeData($data)
    {
        foreach ($data as $attribute => $info) {
            if (is_array($info)) {
                if (count($info) == 1) {
                    $data[$attribute] = $info[0];
                    continue;
                }
            }
        }
        return $data;
    }
1276646
private function prepareData(array $data)
    {
        $inserts = array_dot($data);
        $updates = [];
        $deletes = [];

        foreach ($this->model()->lists('key') as $key) {
            if (isset($inserts[$key]))
                $updates[$key] = $inserts[$key];
            else
                $deletes[]     = $key;

            unset($inserts[$key]);
        }

        return [$inserts, $updates, $deletes];
    }
706167
private function generateAttachmentFields(array $data): array
    {
        $fields = array();
        foreach ($this->normalizerFormatter->format($data) as $key => $value) {
            $fields[] = $this->generateAttachmentField($key, $value);
        }

        return $fields;
    }
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;
    }
793177
protected function extractData(array $data)
    {
        $converted = array();

        foreach ($data as $value) {

            if ($value instanceof Result) {

                $converted[$value->getId()] = $value->getData();
            }
        }

        return $converted;
    }
1191670
protected function getLengths(array $data)
    {
        for ($i = 0; $i < $this->columns; $i++) {
            $this->maxLength[$i] = 0;
            foreach ($this->headers as $field) {
                $field = strip_tags($field);
                if (strlen($field) > $this->maxLength[$i]) {
                    $this->maxLength[$i] = strlen($field);
                }
            }
        }

        foreach ($data as $row) {
            $i = 0;
            foreach ($row as $field) {
                $field = strip_tags($field);
                if (strlen($field) > $this->maxLength[$i]) {
                    $this->maxLength[$i] = strlen($field);
                }
                $i++;
            }
        }
    }