[Added] onActivate/ onDeactivate

This commit is contained in:
MaxBUhe 2024-06-03 12:02:44 +02:00
parent 62ef191d47
commit 10386ccbf5
3 changed files with 72 additions and 1 deletions

30
Setup/Actions.php Normal file
View File

@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
namespace D3\GoogleAnalytics4\Setup;
use D3\GoogleAnalytics4\Application\Model\Constants;
use OxidEsales\Eshop\Core\Registry;
class Actions
{
/**
* @param string $sVarType
* @param string $sSettingName
* @param string $sSettingValue
* @return void
*/
public function d3SaveDefaultSettings(string $sVarType, string $sSettingName, string $sSettingValue){
$oConfig = Registry::getConfig();
$oConfig->saveShopConfVar(
$sVarType,
Constants::OXID_MODULE_ID.$sSettingName,
$sSettingValue,
$oConfig->getShopId(),
Constants::OXID_MODULE_ID
);
}
}

37
Setup/Events.php Normal file
View File

@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
namespace D3\GoogleAnalytics4\Setup;
class Events
{
/**
* @return void
*/
public static function onActivate()
{
$oActions = oxNew(Actions::class);
$oActions->d3SaveDefaultSettings(
'str',
'_sServersidetagging_js',
'https://www.googletagmanager.com/gtm.js'
);
$oActions->d3SaveDefaultSettings(
'str',
'_sServersidetagging_js',
'https://www.googletagmanager.com/ns.html'
);
$oActions->d3SaveDefaultSettings(
'str',
'_sContainerID',
'GTM-'
);
}
/**
* @return void
*/
public static function onDeactivate(){}
}

View File

@ -175,5 +175,9 @@ $aModule = [
'file' => '/Application/views/blocks/remove_from_cart.tpl',
'position' => 150
]
]
],
'events' => [
'onActivate' => '\D3\GoogleAnalytics4\Setup\Events::onActivate',
'onDeactivate' => '\D3\GoogleAnalytics4\Setup\Events::onDeactivate',
],
];