protected function 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 drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/FileBag.php
@api

File

drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/FileBag.php, line 84

Class

FileBag
FileBag is a container for HTTP headers.

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;
}