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

Breadcrumb

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

function ServerRequestCreator::normalizeFiles

Return an UploadedFile instance array.

Parameters

array $files A array which respect $_FILES structure:

Return value

UploadedFileInterface[]

Throws

\InvalidArgumentException for unrecognized values

1 call to ServerRequestCreator::normalizeFiles()
ServerRequestCreator::fromArrays in vendor/nyholm/psr7-server/src/ServerRequestCreator.php
Create a new server request from a set of arrays.

File

vendor/nyholm/psr7-server/src/ServerRequestCreator.php, line 180

Class

ServerRequestCreator
@author Tobias Nyholm <tobias.nyholm@gmail.com> @author Martijn van der Ven <martijn@vanderven.se>

Namespace

Nyholm\Psr7Server

Code

private function normalizeFiles(array $files) : array {
    $normalized = [];
    foreach ($files as $key => $value) {
        if ($value instanceof UploadedFileInterface) {
            $normalized[$key] = $value;
        }
        elseif (\is_array($value) && isset($value['tmp_name'])) {
            $normalized[$key] = $this->createUploadedFileFromSpec($value);
        }
        elseif (\is_array($value)) {
            $normalized[$key] = $this->normalizeFiles($value);
        }
        else {
            throw new \InvalidArgumentException('Invalid value in files specification');
        }
    }
    return $normalized;
}

API Navigation

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