private $filesystem;
public function __construct( OptimizerServiceInterface
$optimizerService,
MediaServiceInterface
$mediaService,
?FilesystemInterface
$filesystem = null
) { $this->optimizerService =
$optimizerService;
$this->mediaService =
$mediaService;
$this->filesystem =
$filesystem ?
$filesystem :
new Filesystem(new Local(sys_get_temp_dir()));
} /**
* {@inheritdoc}
*/
public function optimize($filepath) { // If the file is on the local filesystem we can optimize it directly
if ($this->mediaService->
getAdapterType() === 'local'
) { $this->optimizerService->
optimize($filepath);