init
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\FileManager\ViewModel;
|
||||
|
||||
use Magento\Framework\View\Element\Block\ArgumentInterface;
|
||||
use Magento\Framework\File\Size;
|
||||
use Esun\FileManager\Model\Config as ModuleConfig;
|
||||
|
||||
class Config implements ArgumentInterface
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ModuleConfig $config,
|
||||
private readonly Size $fileSize
|
||||
) {
|
||||
}
|
||||
|
||||
public function isEnabled(): bool
|
||||
{
|
||||
return $this->config->isEnabled();
|
||||
}
|
||||
|
||||
public function getAllowedExtensions(): string
|
||||
{
|
||||
return implode(', ', $this->config->getAllowedExtensions());
|
||||
}
|
||||
|
||||
public function getMaximumFileSizeMb(): string
|
||||
{
|
||||
$maximumBytes = min(
|
||||
$this->config->getMaximumFileSizeBytes(),
|
||||
$this->fileSize->getMaxFileSize()
|
||||
);
|
||||
|
||||
return number_format($maximumBytes / 1024 / 1024, 2, '.', '');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user