Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
Mime Class Reference

Public Member Functions

 getMimeType ($file)
 

Protected Attributes

 $mimeTypes
 

Detailed Description

Definition at line 9 of file Mime.php.

Member Function Documentation

◆ getMimeType()

getMimeType (   $file)

Get mime type of a file

Parameters
string$file
Returns
string
Exceptions

Definition at line 85 of file Mime.php.

86  {
87  if (!file_exists($file)) {
88  throw new \InvalidArgumentException("File '$file' doesn't exist");
89  }
90 
91  $result = null;
92  $extension = $this->getFileExtension($file);
93 
94  if (function_exists('mime_content_type')) {
95  $result = $this->getNativeMimeType($file);
96  }
97 
98  if (null === $result && isset($this->mimeTypes[$extension])) {
99  $result = $this->mimeTypes[$extension];
100  } elseif (null === $result) {
101  $result = 'application/octet-stream';
102  }
103 
104  return $result;
105  }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17

Field Documentation

◆ $mimeTypes

$mimeTypes
protected

Definition at line 16 of file Mime.php.


The documentation for this class was generated from the following file: