Skip to content

Added custom mimetype helper #14

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 2 commits into from
Dec 12, 2016
Merged

Added custom mimetype helper #14

merged 2 commits into from
Dec 12, 2016

Conversation

Nyholm
Copy link
Member

@Nyholm Nyholm commented Dec 8, 2016

This will fix #10

Is this overkill? I thought about adding this features to ApacheMimeTypeHelper but that makes no sense since you still have to use MultipartStreamBuilder::setMimetypeHelper. Or maybe Im wrong..

Anyhow. This is a way for application developers to extend the MimeTypeHelper without adding new classes.

@Nyholm Nyholm requested a review from dbu December 9, 2016 13:49
Copy link
Contributor

@dbu dbu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me, and i like the approach of keeping it separate from the apache mime type helper.

the class description could be explicit that it falls back to the default mappings from apache mimetype if no custom mapping is found. its kindof expected with this extending the other class, but still makes it more immediately clear.

private $mimetypes = [];

/**
* @param array $mimetypes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am a fan of stating the kindof obvious but maybe not really... i think we should say here that this is a hashmap of extension => mime type

*
* @return $this
*/
public function addMimetype($extension, $mimetype)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am not sure we need an adder for this. the constructor should be enough, its not like we discover mime types at runtime - or is there a use case for that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im not sure this would ever be used, no. But I thought "why not?" This class should only be used in the 1% edge case. And if you are such end case you are probably doing something special and could probably be in a scenario when you want to edit this at runtime.

@dbu dbu merged commit 96e8980 into master Dec 12, 2016
@dbu dbu deleted the issue-10 branch December 12, 2016 10:43
@dbu
Copy link
Contributor

dbu commented Dec 12, 2016

thanks! can you please update the documentation so that this can also be found?

@Nyholm
Copy link
Member Author

Nyholm commented Dec 12, 2016

Of course!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

allow to add custom extension to mime type mapping
2 participants