File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -288,7 +288,7 @@ public function getUploadName(object $obj): string
288
288
*
289
289
* @return string|null The upload directory
290
290
*/
291
- public function getUploadDir (object $ obj ): ?string
291
+ public function getUploadDir (object | array $ obj ): ?string
292
292
{
293
293
if (!$ this ->hasDirectoryNamer ()) {
294
294
return '' ;
Original file line number Diff line number Diff line change 6
6
use Vich \TestBundle \Entity \Article ;
7
7
use Vich \TestBundle \Naming \DummyNamer ;
8
8
use Vich \UploaderBundle \Mapping \PropertyMapping ;
9
+ use Vich \UploaderBundle \Naming \ConfigurableDirectoryNamer ;
9
10
use Vich \UploaderBundle \Naming \DirectoryNamerInterface ;
10
11
use Vich \UploaderBundle \Naming \NamerInterface ;
11
12
use Vich \UploaderBundle \Tests \DummyEntity ;
@@ -157,4 +158,22 @@ public function testErase(): void
157
158
self ::assertNull ($ object ->getMimeTypeField ());
158
159
self ::assertNull ($ object ->getSizeField ());
159
160
}
161
+
162
+ public function testWithArray (): void
163
+ {
164
+ $ prop = new PropertyMapping (
165
+ 'image ' ,
166
+ 'imageName ' ,
167
+ );
168
+
169
+ $ directoryNamer = new ConfigurableDirectoryNamer ();
170
+ $ directoryNamer ->configure ([
171
+ 'directory_path ' => 'fake ' ,
172
+ ]);
173
+ $ prop ->setDirectoryNamer ($ directoryNamer );
174
+
175
+ $ object = [];
176
+ $ actual = $ prop ->getUploadDir ($ object );
177
+ self ::assertEquals ('fake ' , $ actual );
178
+ }
160
179
}
You can’t perform that action at this time.
0 commit comments