Get all the mimetypes for an array of extensions

@param array $extensions
@return array
509456
public static function getMimeTypes(array $extensions)
    {
        $mimetypes = [];
        foreach ($extensions as $extension) {
            $mimetype = static::getMimeByExtension($extension, false);
            if ($mimetype && !in_array($mimetype, $mimetypes)) {
                $mimetypes[] = $mimetype;
            }
        }
        return $mimetypes;
    }
213111
public static function detectByFileExtension($extension)
	{
		static $extensionToMimeTypeMap;

		if (!$extensionToMimeTypeMap)
		{
			$extensionToMimeTypeMap = static::getExtensionToMimeTypeMap();
		}

		if (isset($extensionToMimeTypeMap[$extension]))
		{
			return $extensionToMimeTypeMap[$extension];
		}
	}
1274259
public function getRequiredExtensions()
    {
        $extensions = [];
        if (!$manifest = $this->getManager()->getManifestContents()) {
            return $extensions;
        }

        $data = json_decode($manifest, true);
        $require = (array) array_get($data, 'require');
        foreach ($require as $package => $version) {
            if (mb_substr($package, 0, 4) === 'ext-') {
                $extensions[] = mb_substr($package, 4);
            }
        }

        return $extensions;
    }
483083
public function setExtensions(array $extensions)
    {
        foreach ($extensions as $extension) {
            $this->checkType(CmisExtensionElementInterface::class, $extension);
        }

        $this->extensions = $extensions;
    }
1138632
protected function validateExtensions($extensions): Extensions
    {
        if (empty($extensions)) {
            $extensions = new Extensions(['']);
        }

        if (! $extensions instanceof Extensions) {
            $extensions = new Extensions((array)$extensions);
        }

        return $extensions;
    }
844392
public static function getExtensions(array $mimetypes)
    {
        $extensions = [];
        foreach ($mimetypes as $mimetype) {
            $extension = static::getExtensionByMime($mimetype, false);
            if ($extension && !\in_array($extension, $extensions, true)) {
                $extensions[] = $extension;
            }
        }

        return $extensions;
    }
361729
public function getExtensions()
  {
    $ext = array();

    foreach ($this->Config->get('file-extensions') as $key => $value)
    {
      $ext = array_merge($ext, $value['extensions']);
    }

    return $ext;
  }
742309
public static function GetByExtension( string $extension ) : string
   {

      $normalizedExtension = \strtolower( \ltrim( $extension, '.' ) );

      if ( isset( static::$mimeTypes[ $normalizedExtension ] ) )
      {
         return static::$mimeTypes[ $normalizedExtension ];
      }

      return 'application/octet-stream';

   }
237375
private static function get_mime_type($extension) {
		$mime_type = '';
		switch ($extension) {
			case 'htm' :
			case 'html': $mime_type = 'text/html';
			             break;

			case 'css' : $mime_type = 'text/css';
			             break;

			case 'ico' : $mime_type = 'image/x-icon';
			             break;

			case 'js'  : $mime_type = 'text/javascript';
			             break;

			case 'png' : $mime_type = 'image/png';
			             break;

			case 'gif' : $mime_type = 'image/gif';
			             break;

			case 'jpg' :
			case 'jpeg': $mime_type = 'image/jpeg';
			             break;

			case 'pdf' : $mime_type = 'application/pdf';
						 break;

			case 'txt' : $mime_type = 'text/plain';
						 break;

			case 'svg' : $mime_type = 'image/svg+xml';
						 break;

			default    : $mime_type = 'application/octet-stream';
		}

		return $mime_type;
	}
174928
public function getFiles($extension = NULL) {

		$result = [];
		$glob = $this->path . '*';

		if(!is_null($extension)) {
			$glob .= ".$extension";
		}

		foreach(array_filter(glob($glob), 'is_file') as $f) {
			$result[] = FilesystemFile::getInstance($f, $this);
		}

		return $result;
	}
370975
public static function getMissingExtensionIds($extensions) {
        $inList = array();
        foreach ($extensions as $ext) {
            $inList[] = $ext->getId();
        }
        $missing = array();
        foreach ($extensions as $ext) {
            foreach ($ext->getDependencies() as $extId => $version) {
                if (!in_array($extId, $inList) && !in_array($extId, $missing)) {
                    $missing[] = $extId; 
                }
            }
        }
        return $missing;
    }
498309
public static function getExtensionsFromMime($mime, $all = false)
    {
        self::initMimeTypes();

        $result = $all ? [] : '';

        foreach (self::$mimeTypes as $ext => $mimeType)
        {
            if ($mime == $mimeType)
            {
                if ($all)
                {
                    $result[] = $ext;
                }
                else
                {
                    $result = $ext;
                    break;
                }
            }
        }
        return $result;
    }
642895
public function getMimetypeFromExtension($extension)
    {
        static $mimetypes = [
            '7z' => 'application/x-7z-compressed',
            'aac' => 'audio/x-aac',
            'ai' => 'application/postscript',
            'aif' => 'audio/x-aiff',
            'asc' => 'text/plain',
            'asf' => 'video/x-ms-asf',
            'atom' => 'application/atom+xml',
            'avi' => 'video/x-msvideo',
            'bmp' => 'image/bmp',
            'bz2' => 'application/x-bzip2',
            'cer' => 'application/pkix-cert',
            'crl' => 'application/pkix-crl',
            'crt' => 'application/x-x509-ca-cert',
            'css' => 'text/css',
            'csv' => 'text/csv',
            'cu' => 'application/cu-seeme',
            'deb' => 'application/x-debian-package',
            'doc' => 'application/msword',
            'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
            'dvi' => 'application/x-dvi',
            'eot' => 'application/vnd.ms-fontobject',
            'eps' => 'application/postscript',
            'epub' => 'application/epub+zip',
            'etx' => 'text/x-setext',
            'flac' => 'audio/flac',
            'flv' => 'video/x-flv',
            'gif' => 'image/gif',
            'gz' => 'application/gzip',
            'htm' => 'text/html',
            'html' => 'text/html',
            'ico' => 'image/x-icon',
            'ics' => 'text/calendar',
            'ini' => 'text/plain',
            'iso' => 'application/x-iso9660-image',
            'jar' => 'application/java-archive',
            'jpe' => 'image/jpeg',
            'jpeg' => 'image/jpeg',
            'jpg' => 'image/jpeg',
            'js' => 'text/javascript',
            'json' => 'application/json',
            'latex' => 'application/x-latex',
            'log' => 'text/plain',
            'm4a' => 'audio/mp4',
            'm4v' => 'video/mp4',
            'mid' => 'audio/midi',
            'midi' => 'audio/midi',
            'mov' => 'video/quicktime',
            'mp3' => 'audio/mpeg',
            'mp4' => 'video/mp4',
            'mp4a' => 'audio/mp4',
            'mp4v' => 'video/mp4',
            'mpe' => 'video/mpeg',
            'mpeg' => 'video/mpeg',
            'mpg' => 'video/mpeg',
            'mpg4' => 'video/mp4',
            'oga' => 'audio/ogg',
            'ogg' => 'audio/ogg',
            'ogv' => 'video/ogg',
            'ogx' => 'application/ogg',
            'pbm' => 'image/x-portable-bitmap',
            'pdf' => 'application/pdf',
            'pgm' => 'image/x-portable-graymap',
            'png' => 'image/png',
            'pnm' => 'image/x-portable-anymap',
            'ppm' => 'image/x-portable-pixmap',
            'ppt' => 'application/vnd.ms-powerpoint',
            'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
            'ps' => 'application/postscript',
            'qt' => 'video/quicktime',
            'rar' => 'application/x-rar-compressed',
            'ras' => 'image/x-cmu-raster',
            'rss' => 'application/rss+xml',
            'rtf' => 'application/rtf',
            'sgm' => 'text/sgml',
            'sgml' => 'text/sgml',
            'svg' => 'image/svg+xml',
            'swf' => 'application/x-shockwave-flash',
            'tar' => 'application/x-tar',
            'tif' => 'image/tiff',
            'tiff' => 'image/tiff',
            'torrent' => 'application/x-bittorrent',
            'ttf' => 'application/x-font-ttf',
            'txt' => 'text/plain',
            'wav' => 'audio/x-wav',
            'webm' => 'video/webm',
            'wma' => 'audio/x-ms-wma',
            'wmv' => 'video/x-ms-wmv',
            'woff' => 'application/x-font-woff',
            'wsdl' => 'application/wsdl+xml',
            'xbm' => 'image/x-xbitmap',
            'xls' => 'application/vnd.ms-excel',
            'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
            'xml' => 'application/xml',
            'xpm' => 'image/x-xpixmap',
            'xwd' => 'image/x-xwindowdump',
            'yaml' => 'text/yaml',
            'yml' => 'text/yaml',
            'zip' => 'application/zip',

            // Non-Apache standard
            'pkpass' => 'application/vnd.apple.pkpass',
            'msg' => 'application/vnd.ms-outlook',
        ];

        $extension = strtolower($extension);

        return isset($mimetypes[$extension])
            ? $mimetypes[$extension]
            : null;
    }
976251
private static function extractExtensions(array &$parts): array
    {
        $extensions = [];
        while (count($parts) > 1 && strlen($parts[0]) == 1 && strtolower($parts[0]) != 'x') {
            $extension = array_shift($parts);
            $extensions[$extension] = [];
            while (count($parts) > 0 && preg_match('/([a-zA-Z]{2,8})/', $parts[0])) {
                $extensions[$extension][] = array_shift($parts);
            }
        }

        return $extensions;
    }
860769
public function getPaths($extension = null)
	{
		if (isset($extension))
		{
			if (isset($this->paths[$extension]))
			{
				return $this->paths[$extension];
			}

			return;
		}

		return $this->paths;
	}
240393
public function getExtensionsByType()
  {
    $ext = array();

    foreach ($this->Config->get('file-extensions') as $key => $value)
    {
      $ext[$key] = $value['extensions'];
    }

    return $ext;
  }
272156
public function addFormat($format, array $mimeTypes, array $extensions = null)
    {
        $this->formats[$format] = [is_null($extensions) ? [$format] : $extensions, $mimeTypes];

        return $this;
    }