Compare commits

...

5 commits

Author SHA1 Message Date
cff6ac1849
🔖 Release preparations for 2.0.0 2023-05-06 13:01:31 +02:00
8264969c61
Use Context API to check for logged in backend user
The `isBackendUserLoggedIn()` function of the TSFE array is deprecated
starting with TYPO3 v12 and since the Context API also provides the
necssary aspect and functionality in v11 there is no harm in migrating
now.

Refs: #2
2023-05-06 12:55:57 +02:00
89ee94bf28
🐛 Replace check for 'TYPO3_MODE' with check for 'TYPO3'
The TYPO3_MODE variable was deprecated with TYPO3 v11 and replaced
with the TYPO3 constant.

Refs: #2
2023-05-06 12:54:55 +02:00
2af99f3a4d
⬆ Upgrade dependencies to include TYPO3 v12.4
Refs: #2
2023-05-06 12:53:11 +02:00
356360443b
💥 Drop support for TYPO3 v10
TYPO3 v10 is no longer officially supported and I do not want to
invest any time in testing the extension on it.

Refs: #2
2023-05-06 12:50:56 +02:00
5 changed files with 23 additions and 8 deletions

View file

@ -1,5 +1,11 @@
# Changelog # Changelog
## 2.0.0 - 2023-05-06
- 💥 Drop support for TYPO3 v10 (3563604)
- ⬆ Add support for TYPO3 v12 (2af99f3)
- ✨🐛 Resolve deprecations introduced with TYPO3 v11 and v12 (89ee94b, 8264969)
## 1.2.0 - 2022-08-10 ## 1.2.0 - 2022-08-10
- [FEATURE] Add support for TYPO3 v11 and PHP 8.0 & 8.1 (25ccc28, 9c43bfc) - [FEATURE] Add support for TYPO3 v11 and PHP 8.0 & 8.1 (25ccc28, 9c43bfc)

View file

@ -4,6 +4,7 @@ namespace MMK2410\PlausibleAnalytics\Hooks;
use TYPO3\CMS\Core\Page\AssetCollector; use TYPO3\CMS\Core\Page\AssetCollector;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Context\Context;
class PageRendererPreProcess class PageRendererPreProcess
{ {
@ -13,22 +14,30 @@ class PageRendererPreProcess
/** @var \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController */ /** @var \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController */
private $tsfe; private $tsfe;
/** @var Context */
private $context;
public function __construct(AssetCollector $assetCollector = null) public function __construct(AssetCollector $assetCollector = null)
{ {
$this->assetCollector = $assetCollector ?? GeneralUtility::makeInstance(AssetCollector::class); $this->assetCollector = $assetCollector ?? GeneralUtility::makeInstance(AssetCollector::class);
$this->tsfe = $GLOBALS['TSFE'] ?? null; $this->tsfe = $GLOBALS['TSFE'] ?? null;
$this->context = GeneralUtility::makeInstance(Context::class);
} }
public function addLibrary(): void public function addLibrary(): void
{ {
if (!isset($this->tsfe)) { if (!isset($this->tsfe)|| !isset($this->context)) {
return; return;
} }
$domain = $this->getDomain(); $domain = $this->getDomain();
$plausible = $this->getPlausibleURL(); $plausible = $this->getPlausibleURL();
if (isset($domain) && isset($plausible) && !$this->tsfe->isBackendUserLoggedIn()) { if (
isset($domain) &&
isset($plausible) &&
!$this->context->getPropertyFromAspect('backend.user', 'isLoggedIn')
) {
$this->assetCollector->addJavaScript( $this->assetCollector->addJavaScript(
'plausible_analytics', 'plausible_analytics',
$plausible . '/js/plausible.js', $plausible . '/js/plausible.js',

View file

@ -22,8 +22,8 @@
} }
}, },
"require": { "require": {
"php": "7.2.0 - 8.1.99", "php": "7.4.0 - 8.2.99",
"typo3/cms-core": "^10.4 || ^11.5" "typo3/cms-core": "^11.5 || ^12.4"
}, },
"replace": { "replace": {
"typo3-ter/plausible-analytics": "self.version" "typo3-ter/plausible-analytics": "self.version"

View file

@ -8,11 +8,11 @@ $EM_CONF[$_EXTKEY] = [
'author_email' => 'opensource@mmk2410.org', 'author_email' => 'opensource@mmk2410.org',
'state' => 'stable', 'state' => 'stable',
'clearCacheOnLoad' => true, 'clearCacheOnLoad' => true,
'version' => '1.2.0', 'version' => '2.0.0',
'constraints' => [ 'constraints' => [
'depends' => [ 'depends' => [
'typo3' => '10.4.0-11.5.99', 'typo3' => '11.5.0-12.4.99',
'php' => '7.2.0-8.1.99' 'php' => '7.4.0-8.2.99'
], ],
], ],
'autoload' => [ 'autoload' => [

View file

@ -1,6 +1,6 @@
<?php <?php
if (!defined('TYPO3_MODE')) { if (!defined('TYPO3')) {
die('Access denied.'); die('Access denied.');
} }