You are here

protected function FileBag::convertFileInformation in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-foundation/FileBag.php \Symfony\Component\HttpFoundation\FileBag::convertFileInformation()

Converts uploaded files to UploadedFile instances.

Parameters

array|UploadedFile $file A (multi-dimensional) array of uploaded file information:

Return value

array A (multi-dimensional) array of UploadedFile instances

1 call to FileBag::convertFileInformation()
FileBag::set in vendor/symfony/http-foundation/FileBag.php
Sets a parameter by name.

File

vendor/symfony/http-foundation/FileBag.php, line 74

Class

FileBag
FileBag is a container for uploaded files.

Namespace

Symfony\Component\HttpFoundation

Code

protected function convertFileInformation($file) {
  if ($file instanceof UploadedFile) {
    return $file;
  }
  $file = $this
    ->fixPhpFilesArray($file);
  if (is_array($file)) {
    $keys = array_keys($file);
    sort($keys);
    if ($keys == self::$fileKeys) {
      if (UPLOAD_ERR_NO_FILE == $file['error']) {
        $file = null;
      }
      else {
        $file = new UploadedFile($file['tmp_name'], $file['name'], $file['type'], $file['size'], $file['error']);
      }
    }
    else {
      $file = array_map(array(
        $this,
        'convertFileInformation',
      ), $file);
    }
  }
  return $file;
}