Skip to content

Commit b55a8bd

Browse files
committed
CS, simplify
1 parent c874e6f commit b55a8bd

3 files changed

Lines changed: 11 additions & 10 deletions

File tree

classes/GoogleAnalyticsTools.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,8 @@ public function jsonEncodeWithBlacklist($data, $ignoredKeys = [])
280280
*
281281
* @return string render gtag event for output
282282
*/
283-
public function renderEvent($eventName, $eventData, $ignoredKeys = []) {
283+
public function renderEvent($eventName, $eventData, $ignoredKeys = [])
284+
{
284285
return sprintf(
285286
'gtag("event", "%1$s", %2$s);',
286287
$eventName,

classes/Hook/HookDisplayFooterProduct.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
use Configuration;
2424
use Context;
25-
use PrestaShop\Module\Ps_Googleanalytics\GoogleAnalyticsTools;
2625
use PrestaShop\Module\Ps_Googleanalytics\Handler\GanalyticsJsHandler;
2726
use PrestaShop\Module\Ps_Googleanalytics\Wrapper\ProductWrapper;
2827
use Product;
@@ -61,9 +60,9 @@ public function run()
6160
}
6261
// Add product view
6362
if ($isV4Enabled) {
64-
$js = $this->getGoogleAnalytics4($this->module->getTools());
63+
$js = $this->getGoogleAnalytics4();
6564
} else {
66-
$js = $this->getUniversalAnalytics($this->module->getTools());
65+
$js = $this->getUniversalAnalytics();
6766
}
6867

6968
return $gaTagHandler->generate($js);
@@ -79,19 +78,19 @@ public function setParams($params)
7978
$this->params = $params;
8079
}
8180

82-
protected function getUniversalAnalytics(GoogleAnalyticsTools $gaTools)
81+
protected function getUniversalAnalytics()
8382
{
8483
$gaProduct = $this->getProduct();
8584

8685
$js = 'MBG.addProductDetailView(' . json_encode($gaProduct) . ');';
8786
if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST']) > 0) {
88-
$js .= $gaTools->addProductClickByHttpReferal([$gaProduct], $this->context->currency->iso_code);
87+
$js .= $this->module->getTools()->addProductClickByHttpReferal([$gaProduct], $this->context->currency->iso_code);
8988
}
9089

9190
return $js;
9291
}
9392

94-
protected function getGoogleAnalytics4(GoogleAnalyticsTools $gaTools)
93+
protected function getGoogleAnalytics4()
9594
{
9695
$gaProduct = $this->getProduct();
9796
$eventData = [
@@ -115,7 +114,7 @@ protected function getGoogleAnalytics4(GoogleAnalyticsTools $gaTools)
115114
);
116115

117116
if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST']) > 0) {
118-
$js .= $gaTools->addProductClickByHttpReferal([$gaProduct], $this->context->currency->iso_code);
117+
$js .= $this->module->getTools()->addProductClickByHttpReferal([$gaProduct], $this->context->currency->iso_code);
119118
}
120119

121120
return $js;

ps_googleanalytics.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,13 +276,14 @@ public function trans($id, array $parameters = [], $domain = null, $locale = nul
276276
/**
277277
* Returns instance of GoogleAnalyticsTools
278278
*/
279-
public function getTools() {
279+
public function getTools()
280+
{
280281
if ($this->tools === null) {
281282
$this->tools = new PrestaShop\Module\Ps_Googleanalytics\GoogleAnalyticsTools(
282283
(bool) Configuration::get('GA_V4_ENABLED')
283284
);
284285
}
285-
286+
286287
return $this->tools;
287288
}
288289
}

0 commit comments

Comments
 (0)