Browse Source

[HttpFoundation] fixed FileBag to handle sub-requests

Bulat Shakirzyanov 14 năm trước cách đây
mục cha
commit
14e4b9733d
1 tập tin đã thay đổi với 6 bổ sung3 xóa
  1. 6 3
      src/Symfony/Component/HttpFoundation/FileBag.php

+ 6 - 3
src/Symfony/Component/HttpFoundation/FileBag.php

@@ -39,7 +39,7 @@ class FileBag extends ParameterBag
      */
     public function set($key, $value)
     {
-        if (is_array($value)) {
+        if (is_array($value) || $value instanceof UploadedFile) {
             parent::set($key, $this->convertFileInformation($value));
         }
     }
@@ -58,12 +58,15 @@ class FileBag extends ParameterBag
     /**
      * Converts uploaded files to UploadedFile instances.
      *
-     * @param  array $file A (multi-dimensional) array of uploaded file information
+     * @param  array|UploadedFile $file A (multi-dimensional) array of uploaded file information
      *
      * @return array A (multi-dimensional) array of UploadedFile instances
      */
-    protected function convertFileInformation(array $file)
+    protected function convertFileInformation($file)
     {
+        if ($file instanceof UploadedFile) {
+            return $file;
+        }
         $file = $this->fixPhpFilesArray($file);
         if (is_array($file)) {
             $keys = array_keys($file);