diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index f0512a0..f60f6f4 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -1,13 +1,15 @@ in(__DIR__) -; - -$config = new PhpCsFixer\Config(); -return $config->setRules([ - '@PHP73Migration' => true, - '@PSR12' => true - ]) - ->setFinder($finder) -; \ No newline at end of file + + $finder = PhpCsFixer\Finder::create() + ->in(__DIR__) + ; + + $config = new PhpCsFixer\Config(); + return $config->setRules([ + '@PHP81Migration' => true, + '@PSR12' => true, + 'php_unit_test_class_requires_covers' => true, + 'doctrine_annotation_indentation' => true, + ]) + ->setFinder($finder) + ; \ No newline at end of file diff --git a/Application/Component/Widget/d3GtmStartWidget.php b/Application/Component/Widget/d3GtmStartWidget.php index 92a7a79..0f92d33 100644 --- a/Application/Component/Widget/d3GtmStartWidget.php +++ b/Application/Component/Widget/d3GtmStartWidget.php @@ -12,4 +12,4 @@ class d3GtmStartWidget extends \OxidEsales\Eshop\Application\Component\Widget\Wi return ''; } -} \ No newline at end of file +} diff --git a/Application/Controller/Admin/GA4AdminUserInterface_main.php b/Application/Controller/Admin/GA4AdminUserInterface_main.php index b5f5a51..e0701de 100644 --- a/Application/Controller/Admin/GA4AdminUserInterface_main.php +++ b/Application/Controller/Admin/GA4AdminUserInterface_main.php @@ -41,10 +41,10 @@ class GA4AdminUserInterface_main extends \OxidEsales\Eshop\Application\Controlle '_blEnableUsercentricsConsentModeApi', ]; - foreach ($aCheckBoxParams as $checkBoxName){ - if (isset($aParams['bool'][$checkBoxName])){ + foreach ($aCheckBoxParams as $checkBoxName) { + if (isset($aParams['bool'][$checkBoxName])) { $aParams['bool'][$checkBoxName] = true; - }else{ + } else { $aParams['bool'][$checkBoxName] = false; } } @@ -60,8 +60,8 @@ class GA4AdminUserInterface_main extends \OxidEsales\Eshop\Application\Controlle { $oConfig = Registry::getConfig(); foreach ($aParams as $sConfigType => $aConfigParams) { - foreach ($aConfigParams as $sParamName => $sParamValue){ - if($this->d3GetModuleConfigParam($sParamName) !== $sParamValue){ + foreach ($aConfigParams as $sParamName => $sParamValue) { + if ($this->d3GetModuleConfigParam($sParamName) !== $sParamValue) { $oConfig->saveShopConfVar( $sConfigType, Constants::OXID_MODULE_ID.$sParamName, @@ -82,4 +82,4 @@ class GA4AdminUserInterface_main extends \OxidEsales\Eshop\Application\Controlle { return Registry::get(ViewConfig::class)->d3GetModuleConfigParam($configParamName); } -} \ No newline at end of file +} diff --git a/Application/Model/CMP/ConsentManagementPlatformBaseModel.php b/Application/Model/CMP/ConsentManagementPlatformBaseModel.php index dfb6618..b1cc95c 100644 --- a/Application/Model/CMP/ConsentManagementPlatformBaseModel.php +++ b/Application/Model/CMP/ConsentManagementPlatformBaseModel.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace D3\GoogleAnalytics4\Application\Model\CMP; - abstract class ConsentManagementPlatformBaseModel extends \OxidEsales\Eshop\Core\Model\BaseModel implements ConsentManagementPlatformInterface { public string $sCMPName; @@ -16,4 +15,4 @@ abstract class ConsentManagementPlatformBaseModel extends \OxidEsales\Eshop\Core { return $this->sCMPName; } -} \ No newline at end of file +} diff --git a/Application/Model/CMP/ConsentManagementPlatformInterface.php b/Application/Model/CMP/ConsentManagementPlatformInterface.php index 2591738..2099444 100644 --- a/Application/Model/CMP/ConsentManagementPlatformInterface.php +++ b/Application/Model/CMP/ConsentManagementPlatformInterface.php @@ -5,4 +5,4 @@ namespace D3\GoogleAnalytics4\Application\Model\CMP; interface ConsentManagementPlatformInterface { public function getCMPName(); -} \ No newline at end of file +} diff --git a/Application/Model/CMP/Usercentrics.php b/Application/Model/CMP/Usercentrics.php index 9e13404..93910ce 100644 --- a/Application/Model/CMP/Usercentrics.php +++ b/Application/Model/CMP/Usercentrics.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace D3\GoogleAnalytics4\Application\Model\CMP; - use D3\GoogleAnalytics4\Application\Model\ManagerTypes; /** @@ -18,8 +17,8 @@ use D3\GoogleAnalytics4\Application\Model\ManagerTypes; */ class Usercentrics extends ConsentManagementPlatformBaseModel { - const sExternalIncludationPublicName = "( Externe Einbindung ) Usercentrics"; - const sExternalIncludationInternalName = "usercentrics"; - const sModuleIncludationPublicName = "( Modul ) Usercentrics"; - const sModuleIncludationInternalName = "oxps_usercentrics"; -} \ No newline at end of file + public const sExternalIncludationPublicName = "( Externe Einbindung ) Usercentrics"; + public const sExternalIncludationInternalName = "usercentrics"; + public const sModuleIncludationPublicName = "( Modul ) Usercentrics"; + public const sModuleIncludationInternalName = "oxps_usercentrics"; +} diff --git a/Application/Model/Constants.php b/Application/Model/Constants.php index c8035e8..b478051 100644 --- a/Application/Model/Constants.php +++ b/Application/Model/Constants.php @@ -4,8 +4,7 @@ declare(strict_types=1); namespace D3\GoogleAnalytics4\Application\Model; - class Constants { public const OXID_MODULE_ID = 'd3googleanalytics4'; -} \ No newline at end of file +} diff --git a/Application/Model/ManagerHandler.php b/Application/Model/ManagerHandler.php index ee0e577..4c5f1e7 100644 --- a/Application/Model/ManagerHandler.php +++ b/Application/Model/ManagerHandler.php @@ -12,7 +12,7 @@ class ManagerHandler * * @return string */ - public function getCurrManager() :string + public function getCurrManager(): string { /** @var ManagerTypes $oManagerTypes */ $oManagerTypes = oxNew(ManagerTypes::class); @@ -22,15 +22,15 @@ class ManagerHandler $aManagerList = $oManagerTypes->getManagerList(); - if ($this->getModuleSettingExplicitManagerSelectValue()){ + if ($this->getModuleSettingExplicitManagerSelectValue()) { return $this->getExplicitManager(); } - foreach ($aManagerList as $shopModuleId => $publicCMPName){ - if ($oViewConfig->d3IsModuleActive($shopModuleId)){ - $this->d3SaveShopConfVar($shopModuleId); - return $shopModuleId; - } + foreach ($aManagerList as $shopModuleId => $publicCMPName) { + if ($oViewConfig->d3IsModuleActive($shopModuleId)) { + $this->d3SaveShopConfVar($shopModuleId); + return $shopModuleId; + } } return ""; @@ -40,7 +40,8 @@ class ManagerHandler * @param string $sParam * @return void */ - public function d3SaveShopConfVar(string $sParam){ + public function d3SaveShopConfVar(string $sParam) + { Registry::getConfig()->saveShopConfVar( 'select', Constants::OXID_MODULE_ID."_HAS_STD_MANAGER", @@ -53,15 +54,15 @@ class ManagerHandler /** * @return string */ - public function getModuleSettingExplicitManagerSelectValue() :string + public function getModuleSettingExplicitManagerSelectValue(): string { - return Registry::get(ViewConfig::class)->d3GetModuleConfigParam('_HAS_STD_MANAGER')?:""; + return Registry::get(ViewConfig::class)->d3GetModuleConfigParam('_HAS_STD_MANAGER') ?: ""; } /** * @return string */ - public function getExplicitManager() :string + public function getExplicitManager(): string { $sPotentialManagerName = $this->getModuleSettingExplicitManagerSelectValue(); @@ -75,4 +76,4 @@ class ManagerHandler return $sCMPName; } -} \ No newline at end of file +} diff --git a/Application/Model/ManagerTypes.php b/Application/Model/ManagerTypes.php index ab7ada8..26f081f 100644 --- a/Application/Model/ManagerTypes.php +++ b/Application/Model/ManagerTypes.php @@ -6,26 +6,26 @@ use D3\GoogleAnalytics4\Application\Model\CMP\Usercentrics; class ManagerTypes { - const EXTERNAL_SERVICE = "eigener Service"; - const INTERNAL_EXTERNAL_SERVICE = "externalService"; - const NET_COOKIE_MANAGER = "Netensio Cookie Manager"; - const INTERNAL_NET_COOKIE_MANAGER = "net_cookie_manager"; + public const EXTERNAL_SERVICE = "eigener Service"; + public const INTERNAL_EXTERNAL_SERVICE = "externalService"; + public const NET_COOKIE_MANAGER = "Netensio Cookie Manager"; + public const INTERNAL_NET_COOKIE_MANAGER = "net_cookie_manager"; /** * Further information's: * https://github.com/aggrosoft/oxid-cookie-compliance */ - const AGCOOKIECOMPLIANCE = "Aggrosoft Cookie Compliance"; - const INTERNAL_AGCOOKIECOMPLIANCE = "agcookiecompliance"; + public const AGCOOKIECOMPLIANCE = "Aggrosoft Cookie Compliance"; + public const INTERNAL_AGCOOKIECOMPLIANCE = "agcookiecompliance"; - const CONSENTMANAGER = "Consentmanager"; - const INTERNAL_CONSENTMANAGER = "cmconsentmanager"; + public const CONSENTMANAGER = "Consentmanager"; + public const INTERNAL_CONSENTMANAGER = "cmconsentmanager"; - const COOKIEFIRST = "Cookiefirst"; - const INTERNAL_COOKIEFIRST = "cookiefirst"; + public const COOKIEFIRST = "Cookiefirst"; + public const INTERNAL_COOKIEFIRST = "cookiefirst"; - const COOKIEBOT = "Cookiebot"; - const INTERNAL_COOKIEBOT = "cookiebot"; + public const COOKIEBOT = "Cookiebot"; + public const INTERNAL_COOKIEBOT = "cookiebot"; /** * @return array @@ -48,25 +48,25 @@ class ManagerTypes * @param string $sManager * @return bool */ - public function isManagerInList(string $sManager) :bool + public function isManagerInList(string $sManager): bool { return in_array($sManager, array_keys($this->getManagerList()), true); } - - /** - * @return array - * - * the CMP from this method always needs the script tag delivered to the dom. - */ - public function scriptTagDeliveredByDefaultArray() :array - { - return [ - Usercentrics::sModuleIncludationInternalName, - Usercentrics::sExternalIncludationInternalName, - ManagerTypes::INTERNAL_CONSENTMANAGER, - ManagerTypes::INTERNAL_COOKIEFIRST, - ManagerTypes::INTERNAL_COOKIEBOT, - ManagerTypes::INTERNAL_EXTERNAL_SERVICE - ]; - } -} \ No newline at end of file + + /** + * @return array + * + * the CMP from this method always needs the script tag delivered to the dom. + */ + public function scriptTagDeliveredByDefaultArray(): array + { + return [ + Usercentrics::sModuleIncludationInternalName, + Usercentrics::sExternalIncludationInternalName, + ManagerTypes::INTERNAL_CONSENTMANAGER, + ManagerTypes::INTERNAL_COOKIEFIRST, + ManagerTypes::INTERNAL_COOKIEBOT, + ManagerTypes::INTERNAL_EXTERNAL_SERVICE, + ]; + } +} diff --git a/Application/views/admin_smarty/de/d3googleanalytics4_lang.php b/Application/views/admin_smarty/de/d3googleanalytics4_lang.php index 7608463..be21ed7 100644 --- a/Application/views/admin_smarty/de/d3googleanalytics4_lang.php +++ b/Application/views/admin_smarty/de/d3googleanalytics4_lang.php @@ -1,9 +1,10 @@ 'UTF-8', 'd3mxgoogleanalytics4' => 'Google Analytics 4', @@ -120,4 +121,4 @@ Nachher: src="{Domain}?id={Container-ID}" ', -); \ No newline at end of file +]; diff --git a/Application/views/admin_smarty/de/module_options.php b/Application/views/admin_smarty/de/module_options.php index fed5414..ce5b094 100644 --- a/Application/views/admin_smarty/de/module_options.php +++ b/Application/views/admin_smarty/de/module_options.php @@ -1,4 +1,5 @@ getRequestEscapedParameter('am'); - if ($iAmountArticlesAddedToCart){ + if ($iAmountArticlesAddedToCart) { Registry::getSession()->setVariable('d3GtmAddToCartAmountArticles', $iAmountArticlesAddedToCart); - }else{ + } else { Registry::getSession()->setVariable('d3GtmAddToCartAmountArticles', 1); } @@ -36,7 +36,7 @@ class d3GtmBasketComponentExtension extends d3GtmBasketComponentExtension_parent /** * @return int */ - public function getD3GtmAddToCartAmountArticles() :int + public function getD3GtmAddToCartAmountArticles(): int { $iAmount = Registry::getSession()->getVariable('d3GtmAddToCartAmountArticles'); @@ -48,7 +48,7 @@ class d3GtmBasketComponentExtension extends d3GtmBasketComponentExtension_parent /** * @return bool */ - public function getAddToBasketDecision() :bool + public function getAddToBasketDecision(): bool { $decision = Registry::getSession()->getVariable('d3GtmAddToBasketTrigger'); @@ -66,7 +66,7 @@ class d3GtmBasketComponentExtension extends d3GtmBasketComponentExtension_parent $oArticle = null; - if ($sAnid){ + if ($sAnid) { /** @var Article $oArticle */ $oArticle = oxNew(Article::class); $oArticle->load($sAnid); @@ -74,4 +74,4 @@ class d3GtmBasketComponentExtension extends d3GtmBasketComponentExtension_parent return $oArticle; } -} \ No newline at end of file +} diff --git a/Modules/Application/Controller/ArticleDetailsController.php b/Modules/Application/Controller/ArticleDetailsController.php index a2aee20..55907f2 100644 --- a/Modules/Application/Controller/ArticleDetailsController.php +++ b/Modules/Application/Controller/ArticleDetailsController.php @@ -12,4 +12,4 @@ class ArticleDetailsController extends ArticleDetailsController_parent return $return; } -} \ No newline at end of file +} diff --git a/Modules/Application/Controller/ArticleListController_AddToCartHelpMethods.php b/Modules/Application/Controller/ArticleListController_AddToCartHelpMethods.php index 49ea298..d2b14ae 100644 --- a/Modules/Application/Controller/ArticleListController_AddToCartHelpMethods.php +++ b/Modules/Application/Controller/ArticleListController_AddToCartHelpMethods.php @@ -12,4 +12,4 @@ class ArticleListController_AddToCartHelpMethods extends ArticleListController_A return $render; } -} \ No newline at end of file +} diff --git a/Modules/Application/Controller/BasketController.php b/Modules/Application/Controller/BasketController.php index 79a70af..0694ad1 100644 --- a/Modules/Application/Controller/BasketController.php +++ b/Modules/Application/Controller/BasketController.php @@ -26,7 +26,7 @@ class BasketController extends BasketController_parent * @return void * @throws oxSystemComponentException */ - public function d3GA4getRemovedArticlesListObject() :void + public function d3GA4getRemovedArticlesListObject(): void { $this->addTplParam('hasBeenReloaded', false); // collecting items to add @@ -52,7 +52,7 @@ class BasketController extends BasketController_parent 'am' => $dAmount, 'sel' => $aSel, 'persparam' => $aPersParam, - 'basketitemid' => $sBasketItemId + 'basketitemid' => $sBasketItemId, ]; } @@ -84,9 +84,9 @@ class BasketController extends BasketController_parent #dumpVar($this->getBasketArticles()); /** @var Article $item */ - foreach ($oArtList->getArray() as $item){ - foreach ($artIdOnArtAmountList as $artId => $artAmount){ - if ($item->getId() === $artId){ + foreach ($oArtList->getArray() as $item) { + foreach ($artIdOnArtAmountList as $artId => $artAmount) { + if ($item->getId() === $artId) { $item->assign(['d3AmountThatGotRemoved' => $artAmount]); } } @@ -104,13 +104,13 @@ class BasketController extends BasketController_parent * if that doesn't work, we check if there's an Article in the Products array, that has "'am' = 0" * Which also shows we're in that state rn */ - protected function isArticleRemovedState(array $productsArray) :bool + protected function isArticleRemovedState(array $productsArray): bool { if (Registry::getRequest()->getRequestEscapedParameter('removeBtn') or Registry::getRequest()->getRequestEscapedParameter('updateBtn') - ){ + ) { return true; - }else{ + } else { foreach ($productsArray as $aProduct) { if (intval($aProduct['am']) === 0) { return true; diff --git a/Modules/Application/Controller/ThankYouController.php b/Modules/Application/Controller/ThankYouController.php index 250d7c5..2f3acfa 100644 --- a/Modules/Application/Controller/ThankYouController.php +++ b/Modules/Application/Controller/ThankYouController.php @@ -22,4 +22,4 @@ class ThankYouController extends ThankYouController_parent return $oCountry; } -} \ No newline at end of file +} diff --git a/Modules/Application/Controller/d3GtmAccountNoticeListController.php b/Modules/Application/Controller/d3GtmAccountNoticeListController.php index a61efb3..fbbe5a4 100644 --- a/Modules/Application/Controller/d3GtmAccountNoticeListController.php +++ b/Modules/Application/Controller/d3GtmAccountNoticeListController.php @@ -16,4 +16,4 @@ class d3GtmAccountNoticeListController extends d3GtmAccountNoticeListController_ return $return; } -} \ No newline at end of file +} diff --git a/Modules/Application/Controller/d3GtmAccountRecommlistController.php b/Modules/Application/Controller/d3GtmAccountRecommlistController.php index 4e1dc98..b3b3abe 100644 --- a/Modules/Application/Controller/d3GtmAccountRecommlistController.php +++ b/Modules/Application/Controller/d3GtmAccountRecommlistController.php @@ -16,4 +16,4 @@ class d3GtmAccountRecommlistController extends d3GtmAccountRecommlistController_ return $return; } -} \ No newline at end of file +} diff --git a/Modules/Application/Controller/d3GtmAccountWishlistController.php b/Modules/Application/Controller/d3GtmAccountWishlistController.php index 0a6e9aa..6b132b8 100644 --- a/Modules/Application/Controller/d3GtmAccountWishlistController.php +++ b/Modules/Application/Controller/d3GtmAccountWishlistController.php @@ -16,4 +16,4 @@ class d3GtmAccountWishlistController extends d3GtmAccountWishlistController_pare return $return; } -} \ No newline at end of file +} diff --git a/Modules/Application/Controller/d3GtmManufacturerListController.php b/Modules/Application/Controller/d3GtmManufacturerListController.php index 8064beb..d8a41e1 100644 --- a/Modules/Application/Controller/d3GtmManufacturerListController.php +++ b/Modules/Application/Controller/d3GtmManufacturerListController.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace D3\GoogleAnalytics4\Modules\Application\Controller; - class d3GtmManufacturerListController extends d3GtmManufacturerListController_parent { public function render() @@ -15,4 +14,4 @@ class d3GtmManufacturerListController extends d3GtmManufacturerListController_pa return $return; } -} \ No newline at end of file +} diff --git a/Modules/Application/Controller/d3GtmSearchController.php b/Modules/Application/Controller/d3GtmSearchController.php index 213937b..fdde8f0 100644 --- a/Modules/Application/Controller/d3GtmSearchController.php +++ b/Modules/Application/Controller/d3GtmSearchController.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace D3\GoogleAnalytics4\Modules\Application\Controller; - class d3GtmSearchController extends d3GtmSearchController_parent { /** @@ -14,10 +13,10 @@ class d3GtmSearchController extends d3GtmSearchController_parent { $return = parent::render(); - if (false === in_array('oxcmp_basket', $this->getComponents())){ + if (false === in_array('oxcmp_basket', $this->getComponents())) { $this->addTplParam('d3CmpBasket', $this->getComponent('oxcmp_basket')); } return $return; } -} \ No newline at end of file +} diff --git a/Modules/Application/Controller/d3GtmStartController.php b/Modules/Application/Controller/d3GtmStartController.php index 67816ce..832a49e 100644 --- a/Modules/Application/Controller/d3GtmStartController.php +++ b/Modules/Application/Controller/d3GtmStartController.php @@ -10,10 +10,10 @@ class d3GtmStartController extends d3GtmStartController_parent { $return = parent::render(); - if (false === in_array('oxcmp_basket', $this->getComponents())){ + if (false === in_array('oxcmp_basket', $this->getComponents())) { $this->addTplParam('d3CmpBasket', $this->getComponent('oxcmp_basket')); } return $return; } -} \ No newline at end of file +} diff --git a/Modules/Application/Model/Basket.php b/Modules/Application/Model/Basket.php index 2cde7ef..6092702 100644 --- a/Modules/Application/Model/Basket.php +++ b/Modules/Application/Model/Basket.php @@ -9,15 +9,15 @@ class Basket extends Basket_parent /** * @return string */ - public function getPaymentOnPaymentId() :string + public function getPaymentOnPaymentId(): string { - if ($this->getPaymentId()){ + if ($this->getPaymentId()) { $oPayment = oxNew(Payment::class); - if ($oPayment->load($this->getPaymentId())){ + if ($oPayment->load($this->getPaymentId())) { return $oPayment->getFieldData('oxdesc'); } } return "couldn't load payment!"; } -} \ No newline at end of file +} diff --git a/Modules/Application/Model/Category.php b/Modules/Application/Model/Category.php index 42c3cb7..93f3086 100644 --- a/Modules/Application/Model/Category.php +++ b/Modules/Application/Model/Category.php @@ -5,4 +5,4 @@ namespace D3\GoogleAnalytics4\Modules\Application\Model; class Category extends Category_parent { use articleTreeStructure; -} \ No newline at end of file +} diff --git a/Modules/Application/Model/Manufacturer.php b/Modules/Application/Model/Manufacturer.php index 3bf2de6..7876969 100644 --- a/Modules/Application/Model/Manufacturer.php +++ b/Modules/Application/Model/Manufacturer.php @@ -5,4 +5,4 @@ namespace D3\GoogleAnalytics4\Modules\Application\Model; class Manufacturer extends Manufacturer_parent { use articleTreeStructure; -} \ No newline at end of file +} diff --git a/Modules/Application/Model/Vendor.php b/Modules/Application/Model/Vendor.php index 87caded..9b4d02f 100644 --- a/Modules/Application/Model/Vendor.php +++ b/Modules/Application/Model/Vendor.php @@ -4,8 +4,7 @@ declare(strict_types=1); namespace D3\GoogleAnalytics4\Modules\Application\Model; - class Vendor extends \OxidEsales\Eshop\Application\Model\Vendor { use articleTreeStructure; -} \ No newline at end of file +} diff --git a/Modules/Application/Model/articleTreeStructure.php b/Modules/Application/Model/articleTreeStructure.php index 2389f88..a3b12df 100644 --- a/Modules/Application/Model/articleTreeStructure.php +++ b/Modules/Application/Model/articleTreeStructure.php @@ -8,9 +8,9 @@ trait articleTreeStructure * @param int $indexOfArray * @return string */ - public function getSplitCategoryArray(int $indexOfArray = -1, bool $bShallTakeStd = false) :string + public function getSplitCategoryArray(int $indexOfArray = -1, bool $bShallTakeStd = false): string { - if ($bShallTakeStd){ + if ($bShallTakeStd) { $splitCatArray = array_values( array_filter( @@ -26,9 +26,9 @@ trait articleTreeStructure ) ); - if (($indexOfArray >= 0) and (false === empty($splitCatArray[$indexOfArray]))){ + if (($indexOfArray >= 0) and (false === empty($splitCatArray[$indexOfArray]))) { return $splitCatArray[$indexOfArray]; - }else{ + } else { return ""; } } @@ -41,4 +41,4 @@ trait articleTreeStructure ) ); } -} \ No newline at end of file +} diff --git a/Modules/Application/Model/gtmPayment.php b/Modules/Application/Model/gtmPayment.php index b2baa61..619457b 100644 --- a/Modules/Application/Model/gtmPayment.php +++ b/Modules/Application/Model/gtmPayment.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace D3\GoogleAnalytics4\Modules\Application\Model; - use OxidEsales\Eshop\Application\Model\Payment; use OxidEsales\Eshop\Core\Registry; @@ -13,8 +12,8 @@ class gtmPayment extends gtmPayment_parent /** * @return string */ - public function gtmGetSelectedPaymentName() :string + public function gtmGetSelectedPaymentName(): string { - return $this->getFieldData('oxpayments__oxdesc')?: 'No payment name available'; + return $this->getFieldData('oxpayments__oxdesc') ?: 'No payment name available'; } -} \ No newline at end of file +} diff --git a/Modules/Core/ViewConfig.php b/Modules/Core/ViewConfig.php index 9945905..9b07e56 100644 --- a/Modules/Core/ViewConfig.php +++ b/Modules/Core/ViewConfig.php @@ -1,4 +1,5 @@ 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; - } -} \ No newline at end of file + + /** + * @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; + } +} diff --git a/Modules/Core/WidgetControl.php b/Modules/Core/WidgetControl.php index a326a2b..6f5f2d8 100644 --- a/Modules/Core/WidgetControl.php +++ b/Modules/Core/WidgetControl.php @@ -4,7 +4,8 @@ namespace D3\GoogleAnalytics4\Modules\Core; use OxidEsales\EshopCommunity\Core\Registry; -class WidgetControl extends WidgetControl_parent{ +class WidgetControl extends WidgetControl_parent +{ protected function getFrontendStartControllerKey() // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore { /* @@ -27,17 +28,15 @@ class WidgetControl extends WidgetControl_parent{ ) */ $sScriptName = $_SERVER['SCRIPT_NAME']; - if($sScriptName !== '/widget.php') - { + if ($sScriptName !== '/widget.php') { return parent::getFrontendStartControllerKey(); } $aParameter = $_GET; - if(is_null($aParameter['actcontrol']) and is_null($aParameter['oxwparent'])) - { + if (is_null($aParameter['actcontrol']) and is_null($aParameter['oxwparent'])) { return 'D3\GoogleAnalytics4\Application\Component\Widget\d3GtmStartWidget'; } return parent::getFrontendStartControllerKey(); } -} \ No newline at end of file +} diff --git a/Setup/Actions.php b/Setup/Actions.php index 256b834..92bd5ba 100644 --- a/Setup/Actions.php +++ b/Setup/Actions.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace D3\GoogleAnalytics4\Setup; - use D3\GoogleAnalytics4\Application\Model\Constants; use OxidEsales\Eshop\Core\Registry; use OxidEsales\Eshop\Core\ViewConfig; @@ -17,10 +16,11 @@ class Actions * @param string $sSettingValue * @return void */ - public function d3SaveDefaultSettings(string $sVarType, string $sSettingName, string $sSettingValue){ + public function d3SaveDefaultSettings(string $sVarType, string $sSettingName, string $sSettingValue) + { $oConfig = Registry::getConfig(); - if ($this->d3GetModuleConfigParam($sSettingName) and (trim($this->d3GetModuleConfigParam($sSettingName)) !== trim($sSettingValue))){ + if ($this->d3GetModuleConfigParam($sSettingName) and (trim($this->d3GetModuleConfigParam($sSettingName)) !== trim($sSettingValue))) { $sSettingValue = trim($this->d3GetModuleConfigParam($sSettingName)); } @@ -41,4 +41,4 @@ class Actions { return Registry::getConfig()->getShopConfVar(Constants::OXID_MODULE_ID.$configParamName, null, Constants::OXID_MODULE_ID); } -} \ No newline at end of file +} diff --git a/Setup/Events.php b/Setup/Events.php index 30ac24e..65f8952 100644 --- a/Setup/Events.php +++ b/Setup/Events.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace D3\GoogleAnalytics4\Setup; - class Events { /** @@ -33,5 +32,7 @@ class Events /** * @return void */ - public static function onDeactivate(){} -} \ No newline at end of file + public static function onDeactivate() + { + } +} diff --git a/composer.json b/composer.json index 4c7d145..c711cbc 100644 --- a/composer.json +++ b/composer.json @@ -37,9 +37,16 @@ "google/apiclient":" ^2.0", "phpstan/phpstan": "^1.10" }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^3.9" + }, "autoload": { "psr-4": { "D3\\GoogleAnalytics4\\": "" } + }, + "scripts": { + "php-cs-fixer_audit": "./vendor/bin/php-cs-fixer list-files --config=./vendor/d3/google-analytics4/.php-cs-fixer.php", + "php-cs-fixer_fix": "./vendor/bin/php-cs-fixer fix --config=./vendor/d3/google-analytics4/.php-cs-fixer.php" } } \ No newline at end of file diff --git a/metadata.php b/metadata.php index 0fb68e3..58cebc5 100755 --- a/metadata.php +++ b/metadata.php @@ -57,7 +57,7 @@ $aModule = [ 'email' => 'support@shopmodule.com', 'url' => 'https://www.oxidmodule.com/', 'controllers' => [ - 'd3googleanalytics4_main' => GA4AdminUserInterfaceMainController::class + 'd3googleanalytics4_main' => GA4AdminUserInterfaceMainController::class, ], 'extend' => [ // Core @@ -114,45 +114,48 @@ $aModule = [ 'template' => 'layout/base.tpl', 'block' => 'head_meta_robots', 'file' => 'views/smarty/blocks/_gtm_js.tpl', - 'position' => 150 + 'position' => 150, ], // tag manager nojs [ 'template' => 'layout/base.tpl', 'block' => 'theme_svg_icons', - 'file' => 'views/smarty/blocks/_gtm_nojs.tpl' + 'file' => 'views/smarty/blocks/_gtm_nojs.tpl', + 'position' => 150, ], // details [ 'template' => 'page/details/inc/productmain.tpl', 'block' => 'details_productmain_title', 'file' => 'views/smarty/blocks/view_item.tpl', - 'position' => 150 + 'position' => 150, ], // View Cart [ 'template' => 'page/checkout/basket.tpl', 'block' => 'checkout_basket_main', - 'file' => 'views/smarty/blocks/view_cart.tpl' + 'file' => 'views/smarty/blocks/view_cart.tpl', + 'position' => 150, ], // add_to_cart [ 'template' => 'page/details/inc/productmain.tpl', 'block' => 'details_productmain_tobasket', 'file' => 'views/smarty/blocks/details_productmain_tobasket.tpl', - 'position' => 150 + 'position' => 150, ], // remove_from_cart [ 'template' => 'page/checkout/basket.tpl', 'block' => 'checkout_basket_main', 'file' => 'views/smarty/blocks/remove_from_cart.tpl', - 'position' => 150 + 'position' => 150, ], [ 'template' => 'page/checkout/thankyou.tpl', 'block' => 'checkout_thankyou_main', - 'file' => 'views/smarty/blocks/purchase.tpl' + 'file' => 'views/smarty/blocks/purchase.tpl', + 'position' => 150, ], // Lists // view_item_list @@ -160,26 +163,26 @@ $aModule = [ 'template' => 'page/list/list.tpl', 'block' => 'page_list_productlist', 'file' => 'views/smarty/blocks/view_item_list.tpl', - 'position' => 150 + 'position' => 150, ], // view_search_result [ 'template' => 'page/search/search.tpl', 'block' => 'search_results', 'file' => 'views/smarty/blocks/view_search_result.tpl', - 'position' => 150 + 'position' => 150, ], [ 'template' => 'page/list/list.tpl', 'block' => 'page_list_listbody', 'file' => 'views/smarty/blocks/page_list_listbody.tpl', - 'position' => 150 + 'position' => 150, ], [ 'template' => 'page/shop/start.tpl', 'block' => 'start_welcome_text', 'file' => 'views/smarty/blocks/start_welcome_text.tpl', - 'position' => 150 + 'position' => 150, ], // Checkout process // Begin CHeckout @@ -187,7 +190,7 @@ $aModule = [ 'template' => 'page/checkout/user.tpl', 'block' => 'checkout_user_main', 'file' => 'views/smarty/blocks/begin_checkout.tpl', - 'position' => 150 + 'position' => 150, ], // Add payment info // We add it into checkout_order_main ( checkout/order.tpl ) to make sure a payment is actually added; @@ -196,11 +199,11 @@ $aModule = [ 'template' => 'page/checkout/order.tpl', 'block' => 'checkout_order_main', 'file' => 'views/smarty/blocks/add_payment_info.tpl', - 'position' => 150 + 'position' => 150, ], ], 'events' => [ 'onActivate' => '\D3\GoogleAnalytics4\Setup\Events::onActivate', 'onDeactivate' => '\D3\GoogleAnalytics4\Setup\Events::onDeactivate', ], -]; \ No newline at end of file +]; diff --git a/views/smarty/admin/d3googleanalytics4_main.tpl b/views/smarty/admin/d3googleanalytics4_main.tpl index 57a8b51..34c66d7 100644 --- a/views/smarty/admin/d3googleanalytics4_main.tpl +++ b/views/smarty/admin/d3googleanalytics4_main.tpl @@ -1,4 +1,4 @@ -[{include file="ga4/admin/d3ga4uiheaditem.tpl" title="GENERAL_ADMIN_TITLE"|oxmultilangassign}] +[{include file="@d3googleanalytics4/admin/d3ga4uiheaditem.tpl" title="GENERAL_ADMIN_TITLE"|oxmultilangassign}]