Merge pull request #14316 from eileenmcnaughton/membershipRenewal
[civicrm-core.git] / CRM / Utils / File.php
index b51905f71496dfb2ae0e9d56a922130476bd2322..efd0b79c6141a4e279011617bbc0ebcbf1840949 100644 (file)
@@ -1066,4 +1066,29 @@ HTACCESS;
     return FALSE;
   }
 
+  /**
+   * Get the extensions that this MimeTpe is for
+   * @param string $mimeType the mime-type we want extensions for
+   * @return array
+   */
+  public static function getAcceptableExtensionsForMimeType($mimeType = NULL) {
+    $mapping = \MimeType\Mapping::$types;
+    $extensions = [];
+    foreach ($mapping as $extension => $type) {
+      if ($mimeType == $type) {
+        $extensions[] = $extension;
+      }
+    }
+    return $extensions;
+  }
+
+  /**
+   * Get the extension of a file based on its path
+   * @param string $path path of the file to query
+   * @return string
+   */
+  public static function getExtensionFromPath($path) {
+    return pathinfo($path, PATHINFO_EXTENSION);
+  }
+
 }