Refactor MimeTypeTools as a service
modifié: core/lib/Thelia/Config/Resources/config.xml modifié: core/lib/Thelia/Controller/Admin/FileController.php modifié: core/lib/Thelia/Tools/MimeTypeTools.php
This commit is contained in:
@@ -138,6 +138,7 @@
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="tools.mime_type" class="Thelia\Tools\MimeTypeTools" />
|
||||
<!-- Archive builders -->
|
||||
|
||||
<service id="thelia.manager.archive_builder_manager" class="Thelia\Core\FileFormat\Archive\ArchiveBuilderManager">
|
||||
|
||||
@@ -54,6 +54,16 @@ class FileController extends BaseAdminController
|
||||
return $this->container->get('thelia.file_manager');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mime type tools
|
||||
*
|
||||
* @return MimeTypeTools
|
||||
*/
|
||||
public function getMimeTypeTools()
|
||||
{
|
||||
return $this->container->get('tools.mime_type');
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage how a file collection has to be saved
|
||||
*
|
||||
@@ -97,7 +107,7 @@ class FileController extends BaseAdminController
|
||||
}
|
||||
|
||||
$mimeType = $fileBeingUploaded->getMimeType();
|
||||
$mimeTypeTools = MimeTypeTools::getInstance();
|
||||
$mimeTypeTools = $this->getMimeTypeTools();
|
||||
$validateMimeType = $mimeTypeTools
|
||||
->validateMimeTypeExtension(
|
||||
$mimeType,
|
||||
|
||||
@@ -27,22 +27,8 @@ class MimeTypeTools
|
||||
const TYPE_NOT_MATCH = 1;
|
||||
const TYPE_MATCH = 2;
|
||||
|
||||
protected static $instance;
|
||||
|
||||
protected static $typesCache;
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
if (null === static::$instance) {
|
||||
static::$instance = new static();
|
||||
}
|
||||
|
||||
return static::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $mimeType
|
||||
* @return array|bool
|
||||
|
||||
Reference in New Issue
Block a user