ltsecurityinc安防产品在线商城代码
This commit is contained in:
+110
@@ -0,0 +1,110 @@
|
||||
<?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\Setup\Patch\Data;
|
||||
|
||||
use Magento\Config\Model\ResourceModel\Config\Data\CollectionFactory;
|
||||
use Magento\Framework\App\Config\Storage\WriterInterface;
|
||||
use Magento\Framework\Serialize\Serializer\Json;
|
||||
use Magento\Framework\Setup\Patch\DataPatchInterface;
|
||||
use Plumrocket\CookieConsentPro\Model\Integration\MicrosoftClarity as MicrosoftClarityConfig;
|
||||
|
||||
/**
|
||||
* @since 1.1.0
|
||||
*/
|
||||
class MigrateMicrosoftClarityConfigToV2 implements DataPatchInterface
|
||||
{
|
||||
private const V2_CONSENT_TYPES = [
|
||||
'item1' => [
|
||||
'consent_type' => 'ad_Storage',
|
||||
'status' => 'denied',
|
||||
'cookie_category' => null,
|
||||
],
|
||||
'item2' => [
|
||||
'consent_type' => 'analytics_Storage',
|
||||
'status' => 'denied',
|
||||
'cookie_category' => null,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* @var \Magento\Config\Model\ResourceModel\Config\Data\CollectionFactory
|
||||
*/
|
||||
private $configDataCollectionFactory;
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\App\Config\Storage\WriterInterface
|
||||
*/
|
||||
private $configWriter;
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\Serialize\Serializer\Json
|
||||
*/
|
||||
private $jsonSerializer;
|
||||
|
||||
/**
|
||||
* @param \Magento\Config\Model\ResourceModel\Config\Data\CollectionFactory $configDataCollectionFactory
|
||||
* @param \Magento\Framework\App\Config\Storage\WriterInterface $configWriter
|
||||
* @param \Magento\Framework\Serialize\Serializer\Json $jsonSerializer
|
||||
*/
|
||||
public function __construct(
|
||||
CollectionFactory $configDataCollectionFactory,
|
||||
WriterInterface $configWriter,
|
||||
Json $jsonSerializer
|
||||
) {
|
||||
$this->configDataCollectionFactory = $configDataCollectionFactory;
|
||||
$this->configWriter = $configWriter;
|
||||
$this->jsonSerializer = $jsonSerializer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function apply()
|
||||
{
|
||||
$legacyCategoryConfigs = $this->configDataCollectionFactory->create();
|
||||
$legacyCategoryConfigs->addFieldToFilter('path', 'pr_cookie/integrations/microsoft_clarity/category');
|
||||
|
||||
/** @var \Magento\Framework\App\Config\Value $legacyCategoryConfig */
|
||||
foreach ($legacyCategoryConfigs as $legacyCategoryConfig) {
|
||||
$categoryKey = (string) $legacyCategoryConfig->getValue();
|
||||
if (! $categoryKey) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$configDataItemValue = self::V2_CONSENT_TYPES;
|
||||
foreach ($configDataItemValue as $key => $consentType) {
|
||||
$configDataItemValue[$key]['cookie_category'] = $categoryKey;
|
||||
}
|
||||
|
||||
$this->configWriter->save(
|
||||
MicrosoftClarityConfig::XML_PATH_CONSENT_TYPES,
|
||||
$this->jsonSerializer->serialize($configDataItemValue),
|
||||
$legacyCategoryConfig->getScope(),
|
||||
(int) $legacyCategoryConfig->getScopeId()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getDependencies()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getAliases()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
<?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\Setup\Patch\Data;
|
||||
|
||||
use Magento\Framework\Setup\ModuleDataSetupInterface;
|
||||
use Magento\Framework\Setup\Patch\DataPatchInterface;
|
||||
use Plumrocket\CookieConsent\Model\ResourceModel\ConsentLog as ConsentLogResource;
|
||||
use Plumrocket\CookieConsentPro\Api\Data\ConsentLogInterface;
|
||||
use Plumrocket\CookieConsentPro\Model\Config\Source\ConsentInitiator;
|
||||
|
||||
/**
|
||||
* @since 1.0.1
|
||||
*/
|
||||
class UpdateLightVersionConsentLogForPro implements DataPatchInterface
|
||||
{
|
||||
/**
|
||||
* @var \Magento\Framework\Setup\ModuleDataSetupInterface
|
||||
*/
|
||||
private $moduleDataSetup;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\CookieConsent\Model\ResourceModel\ConsentLog
|
||||
*/
|
||||
private $consentLogResource;
|
||||
|
||||
|
||||
/**
|
||||
* @param \Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup
|
||||
* @param \Plumrocket\CookieConsent\Model\ResourceModel\ConsentLog $consentLogResource
|
||||
*/
|
||||
public function __construct(
|
||||
ModuleDataSetupInterface $moduleDataSetup,
|
||||
ConsentLogResource $consentLogResource
|
||||
) {
|
||||
$this->moduleDataSetup = $moduleDataSetup;
|
||||
$this->consentLogResource = $consentLogResource;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function apply()
|
||||
{
|
||||
$setup = $this->moduleDataSetup;
|
||||
$connection = $setup->getConnection();
|
||||
|
||||
$setup->startSetup();
|
||||
$connection->update(
|
||||
$this->consentLogResource->getMainTable(),
|
||||
[ConsentLogInterface::INITIATED_BY => ConsentInitiator::INITIATOR_CUSTOMER],
|
||||
sprintf('%s IS NULL', ConsentLogInterface::INITIATED_BY)
|
||||
);
|
||||
$setup->endSetup();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function getDependencies()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getAliases()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user