[HttpFoundation] Fixed Mimes dependency missing error

This commit is contained in:
Jules Pietri 2020-02-20 20:50:53 +01:00
parent f46ab58bcf
commit fef0de3eb6
No known key found for this signature in database
GPG Key ID: 62E7C545F9D33FCE
2 changed files with 5 additions and 0 deletions

View File

@ -36,6 +36,7 @@ HttpFoundation
* Deprecate `Response::create()`, `JsonResponse::create()`,
`RedirectResponse::create()`, and `StreamedResponse::create()` methods (use
`__construct()` instead)
* Made the Mime component an optional dependency
Messenger
---------

View File

@ -74,6 +74,10 @@ class File extends \SplFileInfo
*/
public function getMimeType()
{
if (!class_exists(MimeTypes::class)) {
throw new \LogicException('You cannot guess the mime type as the Mime component is not installed. Try running "composer require symfony/mime".');
}
return MimeTypes::getDefault()->guessMimeType($this->getPathname());
}