protected function Client::filterFiles

Filters an array of files.

This method created test instances of UploadedFile so that the move() method can be called on those instances.

If the size of a file is greater than the allowed size (from php.ini) then an invalid UploadedFile is returned with an error set to UPLOAD_ERR_INI_SIZE.

Parameters

array $files An array of files:

Return value

array An array with all uploaded files marked as already moved

See also

Symfony\Component\HttpFoundation\File\UploadedFile

1 call to Client::filterFiles()
Client::filterRequest in drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Client.php
Converts the BrowserKit request to a HttpKernel request.

File

drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Client.php, line 152

Class

Client
Client simulates a browser and makes requests to a Kernel object.

Namespace

Symfony\Component\HttpKernel

Code

protected function filterFiles(array $files) {
  $filtered = array();
  foreach ($files as $key => $value) {
    if (is_array($value)) {
      $filtered[$key] = $this
        ->filterFiles($value);
    }
    elseif ($value instanceof UploadedFile) {
      if ($value
        ->isValid() && $value
        ->getSize() > UploadedFile::getMaxFilesize()) {
        $filtered[$key] = new UploadedFile('', $value
          ->getClientOriginalName(), $value
          ->getClientMimeType(), 0, UPLOAD_ERR_INI_SIZE, true);
      }
      else {
        $filtered[$key] = new UploadedFile($value
          ->getPathname(), $value
          ->getClientOriginalName(), $value
          ->getClientMimeType(), $value
          ->getClientSize(), $value
          ->getError(), true);
      }
    }
    else {
      $filtered[$key] = $value;
    }
  }
  return $filtered;
}