init
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\SeventeenTrack\Model;
|
||||
|
||||
use Magento\Framework\App\Config\ScopeConfigInterface;
|
||||
use Magento\Framework\Encryption\EncryptorInterface;
|
||||
|
||||
class Config
|
||||
{
|
||||
private const BASE = 'esun_seventeen_track/';
|
||||
|
||||
public function __construct(
|
||||
private readonly ScopeConfigInterface $scopeConfig,
|
||||
private readonly EncryptorInterface $encryptor
|
||||
) {
|
||||
}
|
||||
|
||||
public function isEnabled(): bool
|
||||
{
|
||||
return $this->scopeConfig->isSetFlag(self::BASE . 'general/enabled');
|
||||
}
|
||||
|
||||
public function getApiUrl(): string
|
||||
{
|
||||
return rtrim((string)$this->scopeConfig->getValue(self::BASE . 'general/api_url'), '/');
|
||||
}
|
||||
|
||||
public function getApiKey(): string
|
||||
{
|
||||
$value = (string)$this->scopeConfig->getValue(self::BASE . 'general/api_key');
|
||||
return $value !== '' ? (string)$this->encryptor->decrypt($value) : '';
|
||||
}
|
||||
|
||||
public function getBatchSize(): int
|
||||
{
|
||||
return min(40, max(1, (int)$this->scopeConfig->getValue(self::BASE . 'sync/batch_size')));
|
||||
}
|
||||
|
||||
public function shouldAutoReceive(): bool
|
||||
{
|
||||
return $this->scopeConfig->isSetFlag(self::BASE . 'sync/auto_receive');
|
||||
}
|
||||
|
||||
public function isWidgetEnabled(): bool
|
||||
{
|
||||
return $this->scopeConfig->isSetFlag(self::BASE . 'widget/enabled');
|
||||
}
|
||||
|
||||
public function getWidgetHeight(): int
|
||||
{
|
||||
return min(800, max(200, (int)$this->scopeConfig->getValue(self::BASE . 'widget/height')));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user