Last active
December 17, 2015 21:19
-
-
Save jeremymoore/5674289 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MimeTypeGuesser extends BaseMimeTypeGuesser | |
{ | |
/** | |
* Constructor overridden since it's private in the base class :/ | |
*/ | |
public function __construct() | |
{ | |
if (FileBinaryMimeTypeGuesser::isSupported()) { | |
$this->register(new FileBinaryMimeTypeGuesser()); | |
} | |
if (FileinfoMimeTypeGuesser::isSupported()) { | |
$this->register(new FileinfoMimeTypeGuesser()); | |
} | |
// register our custom mime type | |
$this->register(new MSFormatMimeTypeGuesser()); | |
} | |
/** | |
* Returns the mime type for a file | |
* | |
* @param \Symfony\Component\HttpFoundation\File\File $file | |
* @return string | |
*/ | |
public function getMimeType(File $file) | |
{ | |
return $this->guess($file->getPathname()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment