Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. FileBag.php

function FileBag::convertFileInformation

Converts uploaded files to UploadedFile instances.

Return value

UploadedFile[]|UploadedFile|null

1 call to FileBag::convertFileInformation()
FileBag::set in vendor/symfony/http-foundation/FileBag.php

File

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

Class

FileBag
FileBag is a container for uploaded files.

Namespace

Symfony\Component\HttpFoundation

Code

protected function convertFileInformation(array|UploadedFile $file) : array|UploadedFile|null {
    if ($file instanceof UploadedFile) {
        return $file;
    }
    $file = $this->fixPhpFilesArray($file);
    $keys = array_keys($file + [
        'full_path' => null,
    ]);
    sort($keys);
    if (self::FILE_KEYS === $keys) {
        if (\UPLOAD_ERR_NO_FILE === $file['error']) {
            $file = null;
        }
        else {
            $file = new UploadedFile($file['tmp_name'], $file['full_path'] ?? $file['name'], $file['type'], $file['error'], false);
        }
    }
    else {
        $file = array_map(fn($v) => $v instanceof UploadedFile || \is_array($v) ? $this->convertFileInformation($v) : $v, $file);
        if (array_is_list($file)) {
            $file = array_filter($file);
        }
    }
    return $file;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal