You are here

class Todo2311679 in ImageMagick 8

Makes possible to guess the MIME type of a file using its extension.

Hierarchy

  • class \Drupal\Core\File\MimeType\ExtensionMimeTypeGuesser implements \Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface

Expanded class hierarchy of Todo2311679

1 string reference to 'Todo2311679'
imagemagick.services.yml in ./imagemagick.services.yml
imagemagick.services.yml
1 service uses Todo2311679
imagemagick.todo2311679 in ./imagemagick.services.yml
Drupal\imagemagick\Todo2311679

File

src/Todo2311679.php, line 15

Namespace

Drupal\imagemagick
View source
class Todo2311679 extends ExtensionMimeTypeGuesser {
  public function getExtensionsForMimeType($mimetype) {
    if ($this->mapping === NULL) {
      $mapping = $this->defaultMapping;

      // Allow modules to alter the default mapping.
      $this->moduleHandler
        ->alter('file_mimetype_mapping', $mapping);
      $this->mapping = $mapping;
    }
    if (!in_array($mimetype, $this->mapping['mimetypes'])) {
      return [];
    }
    $key = array_search($mimetype, $this->mapping['mimetypes']);
    $extensions = array_keys($this->mapping['extensions'], $key, TRUE);
    sort($extensions);
    return $extensions;
  }
  public function getMimeTypes() {
    if ($this->mapping === NULL) {
      $mapping = $this->defaultMapping;

      // Allow modules to alter the default mapping.
      $this->moduleHandler
        ->alter('file_mimetype_mapping', $mapping);
      $this->mapping = $mapping;
    }
    return array_values($this->mapping['mimetypes']);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ExtensionMimeTypeGuesser::$defaultMapping protected property Default MIME extension mapping.
ExtensionMimeTypeGuesser::$mapping protected property The MIME types mapping array after going through the module handler.
ExtensionMimeTypeGuesser::$moduleHandler protected property The module handler.
ExtensionMimeTypeGuesser::guess public function Guesses the mime type of the file with the given path.
ExtensionMimeTypeGuesser::setMapping public function Sets the mimetypes/extension mapping to use when guessing mimetype.
ExtensionMimeTypeGuesser::__construct public function Constructs a new ExtensionMimeTypeGuesser.
Todo2311679::getExtensionsForMimeType public function
Todo2311679::getMimeTypes public function