This commit is contained in:
2026-09-15 10:35:56 +08:00
commit 782f8ea7aa
4086 changed files with 631288 additions and 0 deletions
@@ -0,0 +1,40 @@
<?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;
}
}
@@ -0,0 +1,50 @@
<?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;
}
}
@@ -0,0 +1,17 @@
<?php
declare(strict_types=1);
namespace Esun\Video\Model\Config\Source;
use Magento\Framework\Data\OptionSourceInterface;
class StorageDriver implements OptionSourceInterface
{
public function toOptionArray(): array
{
return [
['value' => 'file', 'label' => __('Local (pub/media)')],
['value' => 'aws-s3', 'label' => __('AWS S3')],
];
}
}