File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
src/Symfony/Component/Mime Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -48,10 +48,11 @@ final class MimeTypes implements MimeTypesInterface
48
48
public function __construct (array $ map = [])
49
49
{
50
50
foreach ($ map as $ mimeType => $ extensions ) {
51
- $ this ->extensions [$ mimeType ] = $ extensions ;
51
+ $ this ->extensions [$ mimeType ] = is_string ( $ extensions ) ? [ $ extensions ] : $ extensions ;
52
52
53
53
foreach ($ extensions as $ extension ) {
54
- $ this ->mimeTypes [$ extension ] = $ mimeType ;
54
+ $ this ->mimeTypes [$ extension ] = $ this ->mimeTypes [$ extension ] ?? [];
55
+ array_push ($ this ->mimeTypes [$ extension ], $ mimeType );
55
56
}
56
57
}
57
58
$ this ->registerGuesser (new FileBinaryMimeTypeGuesser ());
Original file line number Diff line number Diff line change @@ -62,4 +62,16 @@ public function testGetMimeTypes()
62
62
$ this ->assertContains ('image/svg ' , $ mt ->getMimeTypes ('svg ' ));
63
63
$ this ->assertSame ([], $ mt ->getMimeTypes ('symfony ' ));
64
64
}
65
+
66
+
67
+ public function testCustomMimeTypes ()
68
+ {
69
+ $ mt = new MimeTypes ([
70
+ 'text/bar ' => "foo " ,
71
+ 'text/baz ' => ["foo " , "moof " ]
72
+ ]);
73
+ $ this ->assertContains ('text/bar ' , $ mt ->getMimeTypes ('foo ' ));
74
+ $ this ->assertContains ('text/baz ' , $ mt ->getMimeTypes ('foo ' ));
75
+ $ this ->assertSame (["foo " , "moof " ], $ mt ->getExtensions ('text/baz ' ));
76
+ }
65
77
}
You can’t perform that action at this time.
0 commit comments