Files
2026-09-15 10:35:56 +08:00

51 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
namespace Esun\Video\Model\Config\Backend;
use Esun\Video\Model\RemoteStorage\ConfigSynchronizer;
use Magento\Config\Model\Config\Backend\Encrypted;
class RemoteStorageEncrypted extends Encrypted
{
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Framework\App\Config\ScopeConfigInterface $config,
\Magento\Framework\App\Cache\TypeListInterface $cacheTypeList,
\Magento\Framework\Encryption\EncryptorInterface $encryptor,
private readonly ConfigSynchronizer $configSynchronizer,
?\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
?\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
array $data = []
) {
parent::__construct(
$context,
$registry,
$config,
$cacheTypeList,
$encryptor,
$resource,
$resourceCollection,
$data
);
}
public function beforeSave()
{
if ($this->getScope() !== 'default') {
throw new \Magento\Framework\Exception\LocalizedException(
__('Media storage can only be configured at Default Config scope.')
);
}
return parent::beforeSave();
}
public function afterSave()
{
$result = parent::afterSave();
$this->configSynchronizer->synchronize($this);
return $result;
}
}