Elgg\Filesystem\MimeTypeDetector::fixDetectionErrors PHP Метод

fixDetectionErrors() публичный Метод

Fix common type detection errors
public fixDetectionErrors ( string $type, string $extension ) : string
$type string MIME type detected
$extension string Filename extensions
Результат string Fixed MIME type
    public function fixDetectionErrors($type, $extension)
    {
        if ($type === 'application/zip') {
            // hack for Microsoft zipped formats
            switch ($extension) {
                case 'docx':
                    return "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
                case 'xlsx':
                    return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                case 'pptx':
                    return "application/vnd.openxmlformats-officedocument.presentationml.presentation";
            }
        }
        // check for bad ppt detection
        if ($type === "application/vnd.ms-office" && $extension === "ppt") {
            return "application/vnd.ms-powerpoint";
        }
        // try extension detection as a fallback for octet-stream
        if ($type === "application/octet-stream" && $this->use_extension && isset($this->extensions[$extension])) {
            return $this->extensions[$extension];
        }
        return $type;
    }