init
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\FileManager\Model\Config\Backend;
|
||||
|
||||
use Magento\Framework\App\Config\Value;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
|
||||
class UploadPath extends Value
|
||||
{
|
||||
/**
|
||||
* @throws LocalizedException
|
||||
*/
|
||||
public function beforeSave(): self
|
||||
{
|
||||
$path = trim(str_replace('\\', '/', (string) $this->getValue()), '/');
|
||||
if (!preg_match('#^uploads(?:/[a-zA-Z0-9_-]+)*$#', $path)) {
|
||||
throw new LocalizedException(
|
||||
__('Upload Path must be "uploads" or a safe child directory of "uploads".')
|
||||
);
|
||||
}
|
||||
$this->setValue($path);
|
||||
|
||||
return parent::beforeSave();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user