Pimcore\Model\Asset::getTypeFromMimeMapping PHP Method

getTypeFromMimeMapping() public static method

returns the asset type of a filename and mimetype
public static getTypeFromMimeMapping ( $mimeType, $filename ) : integer | string
$mimeType
$filename
return integer | string
    public static function getTypeFromMimeMapping($mimeType, $filename)
    {
        if ($mimeType == "directory") {
            return "folder";
        }
        $type = null;
        $mappings = ["unknown" => ["/\\.stp\$/"], "image" => ["/image/", "/\\.eps\$/", "/\\.ai\$/", "/\\.svgz\$/", "/\\.pcx\$/", "/\\.iff\$/", "/\\.pct\$/", "/\\.wmf\$/"], "text" => ["/text/", "/xml\$/"], "audio" => ["/audio/"], "video" => ["/video/"], "document" => ["/msword/", "/pdf/", "/powerpoint/", "/office/", "/excel/", "/opendocument/"], "archive" => ["/zip/", "/tar/"]];
        foreach ($mappings as $assetType => $patterns) {
            foreach ($patterns as $pattern) {
                if (preg_match($pattern, $mimeType . " ." . File::getFileExtension($filename))) {
                    $type = $assetType;
                    break;
                }
            }
            // break at first match
            if ($type) {
                break;
            }
        }
        if (!$type) {
            $type = "unknown";
        }
        return $type;
    }