diff --git a/src/Flysystem/AssetAdapter.php b/src/Flysystem/AssetAdapter.php index 41c6b8a2..a249596d 100644 --- a/src/Flysystem/AssetAdapter.php +++ b/src/Flysystem/AssetAdapter.php @@ -36,6 +36,16 @@ class AssetAdapter extends LocalFilesystemAdapter */ private static $default_server = 'apache'; + /** + * Default mime type detector to use. If not defined, the default mime type detector from Flysystem will be used. + * If you want to define one, this must be the name of a class that implements the interface + * League\MimeTypeDetection\MimeTypeDetector + * + * @config + * @var string + */ + private static $default_mime_type_detector; + /** * Config compatible permissions configuration * @@ -68,7 +78,19 @@ public function __construct($root = null, $writeFlags = LOCK_EX, $linkHandling = $permissions = PortableVisibilityConverter::fromArray( $this->normalisePermissions($this->config()->get('file_permissions')) ); - parent::__construct($root, $permissions, $writeFlags, $linkHandling); + + // Get the mimetype detector from config, if defined, and ensure it's valid + $mimeTypeDetector = null; + + if ($mimeTypeDetectorClassName = $this->config()->get('default_mime_type_detector')) { + $mimeTypeDetector = Injector::inst()->get($mimeTypeDetectorClassName); + + if (!$mimeTypeDetector instanceof MimeTypeDetector) { + $mimeTypeDetector = null; + } + } + + parent::__construct($root, $permissions, $writeFlags, $linkHandling, $mimeTypeDetector); // Configure server $this->configureServer();