ltsecurityinc安防产品在线商城代码

This commit is contained in:
2026-09-14 17:47:10 +08:00
parent 57d8444c15
commit 6a3c9c5bd8
14539 changed files with 1775310 additions and 0 deletions
@@ -0,0 +1,98 @@
<?php
/**
* @package Plumrocket_CookieConsent
* @copyright Copyright (c) 2022 Plumrocket Inc. (https://plumrocket.com)
* @license https://plumrocket.com/license End-user License Agreement
*/
declare(strict_types=1);
namespace Plumrocket\CookieConsent\Model\Config\Backend;
use Magento\Config\Model\Config\Backend\Serialized\ArraySerialized;
use Magento\Framework\App\Cache\TypeListInterface;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\Data\Collection\AbstractDb;
use Magento\Framework\Model\Context;
use Magento\Framework\Model\ResourceModel\AbstractResource;
use Magento\Framework\Registry;
use Magento\Framework\Serialize\SerializerInterface;
/**
* @since 1.5.0
*/
class ConsentTypes extends ArraySerialized
{
/**
* @var \Magento\Framework\Serialize\SerializerInterface
*/
private $jsonSerializer;
/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
* @param \Magento\Framework\App\Config\ScopeConfigInterface $config
* @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList
* @param \Magento\Framework\Serialize\SerializerInterface $jsonSerializer
* @param \Magento\Framework\Model\ResourceModel\AbstractResource|null $resource
* @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection
* @param array $data
*/
public function __construct(
Context $context,
Registry $registry,
ScopeConfigInterface $config,
TypeListInterface $cacheTypeList,
SerializerInterface $jsonSerializer,
?AbstractResource $resource = null,
?AbstractDb $resourceCollection = null,
array $data = []
) {
parent::__construct(
$context,
$registry,
$config,
$cacheTypeList,
$resource,
$resourceCollection,
$data
);
$this->jsonSerializer = $jsonSerializer;
}
/**
* @inheritdoc
*/
public function beforeSave()
{
parent::beforeSave();
$value = $this->getValue();
if ($value === '[]') {
$this->_dataSaveAllowed = false;
}
}
/**
* Fix get old value.
*
* We have array as default value and magento cannot resolve it by itself
* because it doesn't know how to convert it to string.
*
* @return string
*/
public function getOldValue(): string
{
$oldValue = $this->_config->getValue(
$this->getPath(),
$this->getScope() ?: ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
$this->getScopeCode()
);
if (is_array($oldValue)) {
$oldValue = $this->jsonSerializer->serialize($oldValue);
}
return (string) $oldValue;
}
}