8
0
GoogleAnalytics4/Application/Controller/Admin/GA4AdminUserInterface_main.php

85 Zeilen
2.6 KiB
PHP

2024-05-29 11:39:53 +02:00
<?php
declare(strict_types=1);
namespace D3\GoogleAnalytics4\Application\Controller\Admin;
use D3\GoogleAnalytics4\Application\Model\Constants;
use D3\GoogleAnalytics4\Application\Model\ManagerHandler;
2024-05-29 11:39:53 +02:00
use D3\GoogleAnalytics4\Application\Model\ManagerTypes;
use OxidEsales\Eshop\Core\Registry;
2024-05-29 11:59:38 +02:00
use OxidEsales\Eshop\Core\ViewConfig;
2024-05-29 11:39:53 +02:00
class GA4AdminUserInterface_main extends \OxidEsales\Eshop\Application\Controller\Admin\AdminDetailsController
{
2024-09-21 18:16:52 +02:00
protected $_sThisTemplate = '@' . Constants::OXID_MODULE_ID . '/admin/d3ga4uimain';
2024-05-29 11:39:53 +02:00
public function render()
{
$return = parent::render();
$this->addTplParam('d3ViewObject', $this);
$this->addTplParam('d3ViewConfObject', Registry::get(ViewConfig::class));
2024-05-29 11:39:53 +02:00
$this->addTplParam('d3ManagerTypeArray', oxNew(ManagerTypes::class)->getManagerList());
$this->addTplParam('d3CurrentCMP', oxNew(ManagerHandler::class)->getCurrManager());
2024-05-29 11:39:53 +02:00
return $return;
}
public function save()
{
parent::save();
$aParams = Registry::getRequest()->getRequestEscapedParameter('editval');
$aCheckBoxParams = [
'_blEnableGa4',
'_blEnableDebug',
'_blEnableConsentMode',
'_blEnableOwnCookieManager',
'_blEnableMeasurementCapabilities',
'_blEnableUsercentricsConsentModeApi',
2024-05-29 11:39:53 +02:00
];
foreach ($aCheckBoxParams as $checkBoxName){
if (isset($aParams['bool'][$checkBoxName])){
$aParams['bool'][$checkBoxName] = true;
}else{
$aParams['bool'][$checkBoxName] = false;
}
}
$this->d3SaveShopConfigVars($aParams);
}
/**
* @param array $aParams
* @return void
*/
protected function d3SaveShopConfigVars(array $aParams)
{
$oConfig = Registry::getConfig();
foreach ($aParams as $sConfigType => $aConfigParams) {
foreach ($aConfigParams as $sParamName => $sParamValue){
if($this->d3GetModuleConfigParam($sParamName) !== $sParamValue){
$oConfig->saveShopConfVar(
$sConfigType,
Constants::OXID_MODULE_ID.$sParamName,
$sParamValue,
$oConfig->getShopId(),
Constants::OXID_MODULE_ID
);
}
}
}
}
/**
* @param string $configParamName
* @return mixed
*/
public function d3GetModuleConfigParam(string $configParamName)
{
2024-05-29 11:59:38 +02:00
return Registry::get(ViewConfig::class)->d3GetModuleConfigParam($configParamName);
2024-05-29 11:39:53 +02:00
}
}