Open Journal Systems  3.3.0
Symfony\Component\Mime\MimeTypes Class Reference
Inheritance diagram for Symfony\Component\Mime\MimeTypes:
Symfony\Component\Mime\MimeTypesInterface Symfony\Component\Mime\MimeTypeGuesserInterface

Public Member Functions

 __construct (array $map=[])
 
 getExtensions (string $mimeType)
 
 getMimeTypes (string $ext)
 
 guessMimeType (string $path)
 
 isGuesserSupported ()
 
 registerGuesser (MimeTypeGuesserInterface $guesser)
 

Static Public Member Functions

static getDefault ()
 
static setDefault (self $default)
 

Detailed Description

Manages MIME types and file extensions.

For MIME type guessing, you can register custom guessers by calling the registerGuesser() method. Custom guessers are always called before any default ones:

$guesser = new MimeTypes();
$guesser->registerGuesser(new MyCustomMimeTypeGuesser());

If you want to change the order of the default guessers, just re-register your preferred one as a custom one. The last registered guesser is preferred over previously registered ones.

Re-registering a built-in guesser also allows you to configure it:

$guesser = new MimeTypes();
$guesser->registerGuesser(new FileinfoMimeTypeGuesser('/path/to/magic/file'));
Author
Fabien Potencier fabie.nosp@m.n@sy.nosp@m.mfony.nosp@m..com

Definition at line 37 of file MimeTypes.php.

Constructor & Destructor Documentation

◆ __construct()

Symfony\Component\Mime\MimeTypes::__construct ( array  $map = [])

Definition at line 51 of file MimeTypes.php.

References Symfony\Component\Mime\MimeTypes\registerGuesser().

Member Function Documentation

◆ getDefault()

◆ getExtensions()

Symfony\Component\Mime\MimeTypes::getExtensions ( string  $mimeType)

{Gets the extensions for the given MIME type.

Returns
string[] an array of extensions (first one is the preferred one)
}

Implements Symfony\Component\Mime\MimeTypesInterface.

Definition at line 87 of file MimeTypes.php.

◆ getMimeTypes()

Symfony\Component\Mime\MimeTypes::getMimeTypes ( string  $ext)

{Gets the MIME types for the given extension.

Returns
string[] an array of MIME types (first one is the preferred one)
}

Implements Symfony\Component\Mime\MimeTypesInterface.

Definition at line 99 of file MimeTypes.php.

◆ guessMimeType()

Symfony\Component\Mime\MimeTypes::guessMimeType ( string  $path)

{Guesses the MIME type of the file with the given path.

Parameters
string$pathThe path to the file
Returns
string|null The MIME type or null, if none could be guessed
Exceptions
}

The file is passed to each registered MIME type guesser in reverse order of their registration (last registered is queried first). Once a guesser returns a value that is not null, this method terminates and returns the value.

Implements Symfony\Component\Mime\MimeTypeGuesserInterface.

Definition at line 130 of file MimeTypes.php.

References Symfony\Component\Mime\MimeTypes\isGuesserSupported().

◆ isGuesserSupported()

Symfony\Component\Mime\MimeTypes::isGuesserSupported ( )

{Returns true if this guesser is supported.}

Implements Symfony\Component\Mime\MimeTypeGuesserInterface.

Definition at line 111 of file MimeTypes.php.

Referenced by Symfony\Component\Mime\MimeTypes\guessMimeType().

◆ registerGuesser()

Symfony\Component\Mime\MimeTypes::registerGuesser ( MimeTypeGuesserInterface  $guesser)

Registers a MIME type guesser.

The last registered guesser has precedence over the other ones.

Definition at line 79 of file MimeTypes.php.

Referenced by Symfony\Component\Mime\MimeTypes\__construct().

◆ setDefault()

static Symfony\Component\Mime\MimeTypes::setDefault ( self  $default)
static

Definition at line 64 of file MimeTypes.php.


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