From 09f9578d20be68abf5134f501705ef157b8468be Mon Sep 17 00:00:00 2001 From: Marcel Kapfer Date: Wed, 10 Aug 2022 18:48:26 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Use=20already=20existing?= =?UTF-8?q?=20asset=20collector?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For some reason the AssetCollector instance created (or passed) in the PageRendererPreProcess constructor was not used, but instead a new instance was made as part of the addLibrary function. This commit refactors PageRendererPreProcess::addLibrary to use the already created AssetCollector. --- Classes/Hooks/PageRendererPreProcess.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/Classes/Hooks/PageRendererPreProcess.php b/Classes/Hooks/PageRendererPreProcess.php index 5dc4a0a..02cf04d 100644 --- a/Classes/Hooks/PageRendererPreProcess.php +++ b/Classes/Hooks/PageRendererPreProcess.php @@ -29,16 +29,15 @@ class PageRendererPreProcess $plausible = $this->getPlausibleURL(); if (isset($domain) && isset($plausible) && !$this->tsfe->isBackendUserLoggedIn()) { - GeneralUtility::makeInstance(AssetCollector::class) - ->addJavaScript( - 'plausible_analytics', - $plausible . '/js/plausible.js', - [ - 'async' => 'async', - 'defer' => 'defer', - 'data-domain' => $domain - ], - ); + $this->assetCollector->addJavaScript( + 'plausible_analytics', + $plausible . '/js/plausible.js', + [ + 'async' => 'async', + 'defer' => 'defer', + 'data-domain' => $domain + ], + ); } }