Extract the file uploads from the given data array.

@param  array  $data
@return array
196012
protected function extractFilesFromDataArray(&$data)
    {
        $files = [];

        foreach ($data as $key => $value) {
            if ($value instanceof SymfonyUploadedFile) {
                $files[$key] = $value;

                unset($data[$key]);
            }
        }

        return $files;
    }
391893
public function readFromArray(array $data) : array
    {
        foreach($data as $key => $value)
        {
            if (is_string($value)){
                $value = $this->macro_processor->process($value);
                $data[$key] = $value;
            }
            else if(is_array($value)){
                $data[$key] = $this->readFromArray($value);
            }
        }
        return $data;
    }
27521
public function multipart(array $data = [], $files = false) {

        if(is_array($files)) {

            foreach($files as $name => $file) {

                $data[$name] = $this->file($file);

            }

        }

        $this->params = $data;

        return $this->header(['Content-Type' => 'multipart/form-data']);
    }
954029
public function handleFiles(array $files): array
    {
        $this->removeOldFiles();
        $metadata = [];
        foreach ($files as $file) {
            /**@var $file  UploadedFile */
            if ($file->getError() == UPLOAD_ERR_OK) {
                $originalName = $file->getClientOriginalName();
                $extension = $file->getClientOriginalExtension();
                /**@var $newFile  File */
                if ($newFile = $file->move($this->uploadDir, md5(time().basename($originalName)) . '.' . $extension)) {
                    $metadata[$originalName] = [
                        'host_url'    => $this->hostUrl,
                        'path'        => $newFile->getPathname(),
                        'origin_name' => $originalName,
                        'type'        => $newFile->getMimeType(),
                        'size'        => $newFile->getSize(),
                        'extension'   => $extension
                    ];
                } else {
                    throw new FileUploadException('File upload error');
                }
            }
        }

        return $metadata;
    }
1355221
protected function filter(array $data): array
    {
        $result = [];
        foreach ($data as $key => $value) {
            if ($value['inactive']) {
                continue;
            }

            $result[$key] = $value;
            if (isset($value['children'])) {
                $result[$key]['children'] = $this->filter($value['children']);
            }
        }

        return $result;
    }
1225758
public function parseData(array $data) : array
    {
        if ($this->getTransformer() instanceof RequestTransformerContract) {
            return $this->getTransformer()->transformRequestData($data);
        }

        return $data;
    }
971326
private function _toCleanArray(array $data)
    {
        switch (count($data)) {
            case 0:
                return null;

            case 1:
                if (isset($data[0])) {
                    // Return array content when only one item
                    // with the key 0.
                    if (is_array($data[0])) {
                        return $this->_toCleanArray($data[0]);
                    } else {
                        return $data[0];
                    }
                }
                break;

            case 2:
                if (isset($data[0], $data[1]) && is_string($data[1])) {
                    if (('info' === $data[1]) || ('warning' === $data[1]) || ('error' === $data[1])) {
                        if (is_array($data[0])) {
                            return $this->_toCleanArray($data[0]);
                        } else {
                            return $data[0];
                        }
                    }
                }
        }
        $output = array();
        foreach ($data as $key => $value) {
            if (is_array($value)) {
                $output[$key] = $this->_toCleanArray($value);
            } else {
                if (is_string($value)) {
                    // Filter passwords from the log
                    if (\MUtil_String::contains($key, 'password', true) || \MUtil_String::contains($key, 'pwd', true)) {
                        $value = '****';
                    }
                } elseif ($value instanceof Zend_Date) {
                    // Output iso representation for date objects
                    $value = $value->getIso();
                }
                $output[$key] = $value;
            }
        }

        return $output;
    }
1135567
protected function mergeData(array $data)
    {
        $columns = [];
        foreach ($this->getHeader() as $key => $default) {
            $columns[] = isset($data[$key]) ? $data[$key] : $default;
        }

        return $columns;
    }
54841
private function hydrateIfJsonToArray($data)
    {
        if (is_array($data)) {
            return $data;
        }
        elseif (is_string($data)) {
            $attempt = json_decode($data, true);
            return empty($attempt) ? $data : $attempt;
        }

        return [];
    }
861523
public function upload($data)
    {
        $payload = cradle()->makePayload();
        $payload['request']->setStage('data', $data);

        cradle()->trigger(
            'utility-file-upload',
            $payload['request'],
            $payload['response']
        );

        if(!$payload['response']->hasResults('data')) {
            return $data;
        }

        return $payload['response']->getResults('data');
    }
113026
public function process(array $data)
    {
        $processedData = [
            'meta' => Hash::get($data, 'meta'),
            'data' => []
        ];
        $processedData['meta']['type'] = 'Module';
        $processedData['meta']['title'] = $this->name();
        unset($data['meta']);
        foreach ($data as $attr => $value) {
            $processedData['data'][$attr] = $value;
        }
        return $processedData;
    }
698378
protected function extractAndSetData($data)
    {
        // Attempt to load as Json first, as it's easier to recognise a failure on
        $data_parsed = json_decode($data, true);

        // If there's an error, maybe it's array data? We do this second because parse_str is super-uncaring.
        if (json_last_error() !== JSON_ERROR_NONE) {
            parse_str($data, $data_parsed);
        }

        if (is_array($data_parsed)) {
            $this->setAll($data_parsed);
        }
    }
849414
public function deserialize(array $data)
    {
        $original = $data;
        $this->deserializeTos($data);
        $data = $this->getJavascriptsData($data);
        $data = $this->getLogoData($data);
        unset($data['tos']['text']);
        //maybe move this somewhere else
        unset($data['archives']);

        $data = array_merge($this->serialize([Options::SERIALIZE_MINIMAL]), $data);
        ksort($data);
        $data = json_encode($data, JSON_PRETTY_PRINT);

        file_put_contents($this->filePath, $data);

        return $original;
    }
520481
protected function parseData( array $data, $arrayKey = null )
	{
		if ( is_null( $arrayKey ) )
		{
			$this->files = [];
		}

		foreach ( $data as $key => $value )
		{
			$key = ( $arrayKey ) ? "$arrayKey.$key" : $key;

			// If this value is an instance of the HttpFoundation File class we will
			// remove it from the data array and add it to the files array, which
			// we use to conveniently separate out these files from other data.
			if ( $value instanceof File )
			{
				$this->files[$key] = $value;

				unset( $data[$key] );
			}
			elseif ( is_array( $value ) )
			{
				$this->parseData( $value, $key );
			}
		}

		return $data;
	}
1371449
public function upload($file) {

        if (is_array($file['name'])) {
            $files = $this->reArrayFiles($file);

            $results = [];

            foreach ($files as $singleFile) {
                $result = $this->uploadSingle($singleFile);

                $results[] = $result;
            }

            return $results;

        } else {

            return Array($this->uploadSingle($file));

        }
    }
187710
public function add(array $data = []) : Request
  {
    $this->data = array_merge($this->data, $data);

    $files = array_filter($data, function($file) {
      if (isset($file['type']) && isset($file['name']) && isset($file['size'])) return $file;
    });

    $this->files = array_merge($this->files, $files);
    return $this;
  }
307752
private function extractContentIds($data)
    {
        $ids = [];

        foreach ($data->response->docs as $doc) {
            $ids[] = $doc->content_id_id;
        }

        return $ids;
    }