8000 [2.1] Decouple mimetype-to-extension logic from File class by brki · Pull Request #1386 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[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

Merged
merged 3 commits into from
Sep 6, 2011

Conversation

brki
Copy link
Contributor
@brki brki commented Jun 21, 2011

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.

@@ -467,7 +50,7 @@ class File extends \SplFileInfo
{
$type = $this->getMimeType();

return isset(static::$defaultExtensions[$type]) ? static::$defaultExtensions[$type] : null;
return ExtensionGuesser::guessExtension($type);
Copy link
Member

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

@brki
Copy link
Contributor Author
brki commented Jun 21, 2011

Now implemented similarly to the existing MimeTypeGuesser.

* @return string The guessed extension or NULL, if none could be guessed
*/
function guess($mimeType);

Copy link
Member

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

@brki
Copy link
Contributor Author
brki commented Jun 21, 2011

whitespace removed

@stof
Copy link
Member
stof commented Sep 4, 2011

@fabpot @brki what is the status of this PR ?

fabpot added a commit that referenced this pull request Sep 6, 2011
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 ?
@fabpot fabpot merged commit 34494b3 into symfony:master Sep 6, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0