[Changed] code cleanup

php cs fixer
This commit is contained in:
2024-11-25 18:48:39 +01:00
parent 2cd0652c31
commit c27834536d
47 changed files with 273 additions and 239 deletions

View File

@ -1,4 +1,5 @@
<?php
/**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@ -28,7 +29,6 @@ use Psr\Container\NotFoundExceptionInterface;
class ViewConfig extends ViewConfig_parent
{
// Google Tag Manager Container ID
private $sContainerId = null;
@ -40,8 +40,7 @@ class ViewConfig extends ViewConfig_parent
public function getGtmContainerId()
{
if ($this->sContainerId === null)
{
if ($this->sContainerId === null) {
$this->sContainerId = $this->d3GetModuleConfigParam("_sContainerID");
}
return $this->sContainerId;
@ -50,10 +49,9 @@ class ViewConfig extends ViewConfig_parent
/**
* @return void
*/
public function defineCookieManagerType() :void
public function defineCookieManagerType(): void
{
if ($this->sCookieManagerType === null)
{
if ($this->sCookieManagerType === null) {
/** @var ManagerHandler $oManagerHandler */
$oManagerHandler = oxNew(ManagerHandler::class);
$this->sCookieManagerType = $oManagerHandler->getCurrManager();
@ -63,7 +61,7 @@ class ViewConfig extends ViewConfig_parent
/**
* @return bool
*/
public function shallUseOwnCookieManager() :bool
public function shallUseOwnCookieManager(): bool
{
return (bool) $this->d3GetModuleConfigParam('_blEnableOwnCookieManager');
}
@ -76,7 +74,7 @@ class ViewConfig extends ViewConfig_parent
/** @var Config $oConfig */
$oConfig = Registry::getConfig();
if (false === $this->isGA4enabled()){
if (false === $this->isGA4enabled()) {
return false;
}
@ -103,15 +101,13 @@ class ViewConfig extends ViewConfig_parent
return $this->isCookieCategoryEnabled($sCookieID);
}
}
if (
in_array
(
$this->sCookieManagerType,
(oxNew(ManagerTypes::class)->scriptTagDeliveredByDefaultArray())
)
)
{
in_array(
$this->sCookieManagerType,
(oxNew(ManagerTypes::class)->scriptTagDeliveredByDefaultArray())
)
) {
// Always needs the script-tags delivered to the DOM.
return true;
}
@ -125,32 +121,30 @@ class ViewConfig extends ViewConfig_parent
* This is especially important for UserCentrics.
* @return string
*/
public function getGtmScriptAttributes() :string
public function getGtmScriptAttributes(): string
{
$sControlParameter = trim($this->d3GetModuleConfigParam('_sControlParameter'));
if (false === $this->shallUseOwnCookieManager() or ($sControlParameter === '')){
if (false === $this->shallUseOwnCookieManager() or ($sControlParameter === '')) {
return "";
}
if (
$this->sCookieManagerType === Usercentrics::sModuleIncludationInternalName
or $this->sCookieManagerType === Usercentrics::sExternalIncludationInternalName
)
{
) {
return 'data-usercentrics="' . $sControlParameter . '" type="text/plain" async=""';
}
if ($this->sCookieManagerType === ManagerTypes::INTERNAL_CONSENTMANAGER)
{
if ($this->sCookieManagerType === ManagerTypes::INTERNAL_CONSENTMANAGER) {
return 'type="text/plain" class="cmplazyload" data-cmp-vendor="'.$sControlParameter.'"';
}
if ($this->sCookieManagerType === ManagerTypes::INTERNAL_COOKIEFIRST){
if ($this->sCookieManagerType === ManagerTypes::INTERNAL_COOKIEFIRST) {
return 'type="text/plain" data-cookiefirst-category="' . $sControlParameter .'"';
}
if ($this->sCookieManagerType === ManagerTypes::INTERNAL_COOKIEBOT){
if ($this->sCookieManagerType === ManagerTypes::INTERNAL_COOKIEBOT) {
return 'type="text/plain" data-cookieconsent="' . $sControlParameter .'"';
}
@ -163,22 +157,23 @@ class ViewConfig extends ViewConfig_parent
*/
public function isGA4enabled()
{
if ($this->blGA4enabled === null)
{
if ($this->blGA4enabled === null) {
$this->blGA4enabled = $this->d3GetModuleConfigParam("_blEnableGA4");
}
return $this->blGA4enabled;
}
public function isGtmConsentModeSetActivated() :bool
public function isGtmConsentModeSetActivated(): bool
{
return $this->d3GetModuleConfigParam("_blEnableConsentMode")?: false;
return $this->d3GetModuleConfigParam("_blEnableConsentMode") ?: false;
}
public function getGtmDataLayer()
{
if (!$this->getGtmContainerId()) return "[]";
if (!$this->getGtmContainerId()) {
return "[]";
}
$oConfig = Registry::getConfig();
$oView = $oConfig->getTopActiveView();
@ -213,9 +208,9 @@ class ViewConfig extends ViewConfig_parent
return json_encode([$dataLayer], JSON_PRETTY_PRINT);
}
public function isDebugModeOn() :bool
public function isDebugModeOn(): bool
{
return $this->d3GetModuleConfigParam("_blEnableDebug")?: false;
return $this->d3GetModuleConfigParam("_blEnableDebug") ?: false;
}
/**
@ -223,9 +218,9 @@ class ViewConfig extends ViewConfig_parent
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function getServerSidetaggingJsDomain() :string
public function getServerSidetaggingJsDomain(): string
{
return $this->d3GetModuleConfigParam("_sServersidetagging_js")?: "";
return $this->d3GetModuleConfigParam("_sServersidetagging_js") ?: "";
}
/**
@ -233,9 +228,9 @@ class ViewConfig extends ViewConfig_parent
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function getServerSidetaggingNoJsDomain() :string
public function getServerSidetaggingNoJsDomain(): string
{
return $this->d3GetModuleConfigParam('_sServersidetagging_nojs')?: "";
return $this->d3GetModuleConfigParam('_sServersidetagging_nojs') ?: "";
}
/**
@ -250,7 +245,7 @@ class ViewConfig extends ViewConfig_parent
/**
* @return bool
*/
public function d3IsUsercentricsCMPChosen() :bool
public function d3IsUsercentricsCMPChosen(): bool
{
$sCMPPubName = $this->d3GetModuleConfigParam('_HAS_STD_MANAGER');
$aPossibleCMP = (oxNew(ManagerTypes::class))->getManagerList();
@ -258,26 +253,26 @@ class ViewConfig extends ViewConfig_parent
return (bool) ($sCMPPubName === Usercentrics::sExternalIncludationInternalName
or $sCMPPubName === Usercentrics::sModuleIncludationInternalName);
}
/**
* @return bool
*/
public function d3IsModuleActive(string $sModuleId) :bool
{
/** @var ModuleActivationBridgeInterface $moduleActivationBridge */
$moduleActivationBridge = $this
->getContainer()
->get(ModuleActivationBridgeInterface::class);
try {
$isActiveBool = $moduleActivationBridge->isActive(
$sModuleId,
Registry::getConfig()->getShopId()
);
}catch (\Exception|ModuleConfigurationNotFoundException $e){
return false;
}
return (bool) $isActiveBool;
}
}
/**
* @return bool
*/
public function d3IsModuleActive(string $sModuleId): bool
{
/** @var ModuleActivationBridgeInterface $moduleActivationBridge */
$moduleActivationBridge = $this
->getContainer()
->get(ModuleActivationBridgeInterface::class);
try {
$isActiveBool = $moduleActivationBridge->isActive(
$sModuleId,
Registry::getConfig()->getShopId()
);
} catch (\Exception|ModuleConfigurationNotFoundException $e) {
return false;
}
return (bool) $isActiveBool;
}
}