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,81 @@
<?php
/**
* @package Plumrocket_CookieConsentPro
* @copyright Copyright (c) 2025 Plumrocket Inc.
* @license https://plumrocket.com/license End-user License Agreement
*/
declare(strict_types=1);
namespace Plumrocket\CookieConsentPro\Model\Config\Backend\GlobalPrivacyControl;
use Magento\Framework\App\Config\Value;
/**
* @since 1.0.1
*/
class CookieCategoriesToDecline extends Value
{
/**
* @var \Plumrocket\CookieConsentPro\Model\Config\Source\CookieCategories
*/
private $cookieCategories;
/**
* @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 \Plumrocket\CookieConsentPro\Model\Config\Source\CookieCategories $cookieCategories
* @param \Magento\Framework\Model\ResourceModel\AbstractResource|null $resource
* @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection
* @param array $data
*/
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Framework\App\Config\ScopeConfigInterface $config,
\Magento\Framework\App\Cache\TypeListInterface $cacheTypeList,
\Plumrocket\CookieConsentPro\Model\Config\Source\CookieCategories $cookieCategories,
?\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
);
$this->cookieCategories = $cookieCategories;
}
/**
* Remove essential cookie categories from value before save
*
* @return $this
*/
public function beforeSave()
{
$value = $this->getValue();
if (! is_array($value)) {
$value = explode(',', (string)$value);
}
$disabledCategories = [];
foreach ($this->cookieCategories->toOptionArray() as $option) {
if ($option['isEssential']) {
$disabledCategories[] = $option['value'];
}
}
// Remove essential categories from the value
$value = array_diff($value, $disabledCategories);
$this->setValue($value);
return parent::beforeSave();
}
}