41 lines
1.3 KiB
PHP
41 lines
1.3 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace Esun\Video\Model\Config\Backend;
|
|
|
|
use Esun\Video\Model\RemoteStorage\ConfigSynchronizer;
|
|
use Magento\Framework\App\Config\Value;
|
|
|
|
class RemoteStorage extends Value
|
|
{
|
|
public function __construct(
|
|
\Magento\Framework\Model\Context $context,
|
|
\Magento\Framework\Registry $registry,
|
|
\Magento\Framework\App\Config\ScopeConfigInterface $config,
|
|
\Magento\Framework\App\Cache\TypeListInterface $cacheTypeList,
|
|
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, $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;
|
|
}
|
|
}
|