♻️ Use already existing asset collector

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.
This commit is contained in:
Marcel Kapfer 2022-08-10 18:48:26 +02:00
parent 9c43bfc8f5
commit 09f9578d20
Signed by: mmk2410
GPG Key ID: CADE6F0C09F21B09
1 changed files with 9 additions and 10 deletions

View File

@ -29,16 +29,15 @@ class PageRendererPreProcess
$plausible = $this->getPlausibleURL(); $plausible = $this->getPlausibleURL();
if (isset($domain) && isset($plausible) && !$this->tsfe->isBackendUserLoggedIn()) { if (isset($domain) && isset($plausible) && !$this->tsfe->isBackendUserLoggedIn()) {
GeneralUtility::makeInstance(AssetCollector::class) $this->assetCollector->addJavaScript(
->addJavaScript( 'plausible_analytics',
'plausible_analytics', $plausible . '/js/plausible.js',
$plausible . '/js/plausible.js', [
[ 'async' => 'async',
'async' => 'async', 'defer' => 'defer',
'defer' => 'defer', 'data-domain' => $domain
'data-domain' => $domain ],
], );
);
} }
} }