-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[2.1] Decouple mimetype-to-extension logic from File class #1386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[2.1] Decouple mimetype-to-extension logic from File class #1386
Conversation
@@ -467,7 +50,7 @@ class File extends \SplFileInfo | |||
{ | |||
$type = $this->getMimeType(); | |||
|
|||
return isset(static::$defaultExtensions[$type]) ? static::$defaultExtensions[$type] : null; | |||
return ExtensionGuesser::guessExtension($type); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should not use a static method. This does not allow to replace the guesser implementation
Now implemented similarly to the existing MimeTypeGuesser. |
* @return string The guessed extension or NULL, if none could be guessed | ||
*/ | ||
function guess($mimeType); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should remove this extra line
whitespace removed |
Commits ------- 34494b3 whitespace fixes 1a86a4a Refactor mime-type to file extension guessing e7481a3 Decouple mime-type to extension logic from File class Discussion ---------- [2.1] Decouple mimetype-to-extension logic from File class This allows guessing the extension from a given mime type without requiring the existence of a local file. If a file's meta information (mime-type, etc.) is already available (i.e. it's been extracted once and stored in some persistent data store), it would be nice to be able to make a best-guess on the extension based on the known mime-type. A concrete use case of this is for the symfony-cmf, where a file has been stored in the jackrabbit data store. When delivering this file or saving it to disk, we'd like to use an extension that's created based on the known mime type of the file. --------------------------------------------------------------------------- by brki at 2011/06/21 04:35:13 -0700 Now implemented similarly to the existing MimeTypeGuesser. --------------------------------------------------------------------------- by brki at 2011/06/21 07:51:22 -0700 whitespace removed --------------------------------------------------------------------------- by stof at 2011/09/04 05:04:54 -0700 @fabpot @brki what is the status of this PR ?
This allows guessing the extension from a given mime type
without requiring the existence of a local file.
If a file's meta information (mime-type, etc.) is already available (i.e. it's
been extracted once and stored in some persistent data store), it would be
nice to be able to make a best-guess on the extension based on the known mime-type.
A concrete use case of this is for the symfony-cmf, where a file has been stored
in the jackrabbit data store. When delivering this file or saving it to disk, we'd like to
use an extension that's created based on the known mime type of the file.