76 lines
2.1 KiB
PHP
76 lines
2.1 KiB
PHP
<?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\Setup\Patch\Data;
|
|
|
|
use Magento\Config\Model\ResourceModel\Config\Data\CollectionFactory;
|
|
use Magento\Eav\Setup\EavSetupFactory;
|
|
use Magento\Framework\App\Config\Storage\WriterInterface;
|
|
use Magento\Framework\Setup\Patch\DataPatchInterface;
|
|
use Plumrocket\CookieConsent\Helper\Config;
|
|
|
|
/**
|
|
* @since 1.5.0
|
|
*/
|
|
class DisableConsentModeForOldClients implements DataPatchInterface
|
|
{
|
|
/**
|
|
* @var \Magento\Config\Model\ResourceModel\Config\Data\CollectionFactory
|
|
*/
|
|
private $configDataCollectionFactory;
|
|
|
|
/**
|
|
* @var \Magento\Framework\App\Config\Storage\WriterInterface
|
|
*/
|
|
private $configWriter;
|
|
|
|
/**
|
|
* @param \Magento\Config\Model\ResourceModel\Config\Data\CollectionFactory $configDataCollectionFactory
|
|
* @param \Magento\Framework\App\Config\Storage\WriterInterface $configWriter
|
|
*/
|
|
public function __construct(
|
|
CollectionFactory $configDataCollectionFactory,
|
|
WriterInterface $configWriter
|
|
) {
|
|
$this->configDataCollectionFactory = $configDataCollectionFactory;
|
|
$this->configWriter = $configWriter;
|
|
}
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public function apply()
|
|
{
|
|
/** @var \Magento\Config\Model\ResourceModel\Config\Data\Collection $configDataCollection */
|
|
$configDataCollection = $this->configDataCollectionFactory->create();
|
|
$configDataCollection->addFieldToFilter('path', Config::XML_PATH_GTM_CONTAINER_ID);
|
|
$isGtmAlreadyEnabled = $configDataCollection->getSize();
|
|
|
|
if ($isGtmAlreadyEnabled) {
|
|
$this->configWriter->save(Config::XML_PATH_GTM_CONSENT_MODE_ENABLED, 0);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public static function getDependencies(): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public function getAliases(): array
|
|
{
|
|
return [];
|
|
}
|
|
}
|