class DummyMimeTypeMapLoadedSubscriber

Modifies the MIME type map by adding dummy mappings.

Hierarchy

Expanded class hierarchy of DummyMimeTypeMapLoadedSubscriber

File

core/modules/file/tests/file_test/src/EventSubscriber/DummyMimeTypeMapLoadedSubscriber.php, line 15

Namespace

Drupal\file_test\EventSubscriber
View source
class DummyMimeTypeMapLoadedSubscriber implements EventSubscriberInterface {
  
  /**
   * {@inheritdoc}
   */
  public function onMimeTypeMapLoaded(MimeTypeMapLoadedEvent $event) : void {
    // Add new mappings.
    $event->map
      ->addMapping('made_up/file_test_1', 'file_test_1');
    $event->map
      ->addMapping('made_up/file_test_2', 'file_test_2');
    $event->map
      ->addMapping('made_up/file_test_2', 'file_test_3');
    $event->map
      ->addMapping('application/x-compress', 'z');
    $event->map
      ->addMapping('application/x-tarz', 'tar.z');
    $event->map
      ->addMapping('application/x-garply-waldo', 'garply.waldo');
    // Override existing mapping.
    $event->map
      ->addMapping('made_up/doc', 'doc');
  }
  
  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() : array {
    return [
      MimeTypeMapLoadedEvent::class => 'onMimeTypeMapLoaded',
    ];
  }

}

Members


Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.