Skip to content

Commit

Permalink
v11 compatibility (#67)
Browse files Browse the repository at this point in the history
* [BUGFIX] Fix problem with TypoScriptFrontendController

* [TASK] Make extension key detection compatible with TYPO3 v9 - v11 

* [TASK] Update Readme
  • Loading branch information
peterkraume authored Sep 22, 2021
1 parent bdd33ad commit 79f22e2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
15 changes: 13 additions & 2 deletions Classes/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,19 @@
use Psr\Http\Message\ServerRequestInterface;
use T3Monitor\T3monitoringClient\Provider\DataProviderInterface;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Core\Bootstrap;
use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder;
use TYPO3\CMS\Core\Http\NormalizedParams;
use TYPO3\CMS\Core\Http\Response;
use TYPO3\CMS\Core\Http\ServerRequestFactory;
use TYPO3\CMS\Core\Http\Uri;
use TYPO3\CMS\Core\Routing\PageArguments;
use TYPO3\CMS\Core\Site\Entity\NullSite;
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
use TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;

/**
Expand Down Expand Up @@ -104,13 +108,20 @@ protected function collectData()
if ($isv10) {
// create a dummy TSFE as it is injected into ContentObjectRenderer, which is used indirectly by status reports
$siteLanguage = new SiteLanguage(0, 'en_US', new Uri(), []);
$GLOBALS['TSFE'] = GeneralUtility::makeInstance(TypoScriptFrontendController::class, null, new NullSite(), $siteLanguage);
$GLOBALS['TSFE'] = GeneralUtility::makeInstance(
TypoScriptFrontendController::class,
GeneralUtility::makeInstance(Context::class),
new NullSite(),
$siteLanguage,
new PageArguments(0, '0', []),
GeneralUtility::makeInstance(FrontendUserAuthentication::class)
);
}

// Since 10.4.16, the internal ExtensionProvider requires a request
if (!($GLOBALS['TYPO3_REQUEST'] ?? null)) {
$request = ServerRequestFactory::fromGlobals();
$GLOBALS['TYPO3_REQUEST'] = $request->withAttribute('normalizedParams', NormalizedParams::createFromRequest($request));
$GLOBALS['TYPO3_REQUEST'] = $request->withAttribute('applicationType', SystemEnvironmentBuilder::REQUESTTYPE_FE);
}

foreach ($classes as $class) {
Expand Down
12 changes: 10 additions & 2 deletions Classes/Provider/ExtensionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ class ExtensionProvider implements DataProviderInterface
*/
public function get(array $data)
{
$hasNewEmConfApi = VersionNumberUtility::convertVersionNumberToInteger('10.2') < VersionNumberUtility::convertVersionNumberToInteger(TYPO3_branch);
$isv11 = VersionNumberUtility::convertVersionNumberToInteger('11.2') < VersionNumberUtility::convertVersionNumberToInteger(TYPO3_branch);
$isv10 = VersionNumberUtility::convertVersionNumberToInteger('10.2') < VersionNumberUtility::convertVersionNumberToInteger(TYPO3_branch);
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$listUtility = $objectManager->get(ListUtility::class);

Expand All @@ -42,7 +43,14 @@ public function get(array $data)
continue;
}

$data['extensions'][$key] = $hasNewEmConfApi ? $emConfUtility->includeEmConf($key, $f) : $emConfUtility->includeEmConf($f);
if ($isv11) {
$data['extensions'][$key] = $emConfUtility->includeEmConf($key, $f['packagePath']);
} elseif ($isv10) {
$data['extensions'][$key] = $emConfUtility->includeEmConf($key, $f);
} else {
$data['extensions'][$key] = $emConfUtility->includeEmConf($f);
}

$data['extensions'][$key]['isLoaded'] = (int)ExtensionManagementUtility::isLoaded($key);
}

Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This extensions provides a client for the the extension **t3monitoring**.

**Requirements**

- TYPO3 CMS 9.5 LTS or 10.2+
- TYPO3 CMS 9.5 LTS, 10.4 LTS or 11.3+
- Use the branch `4-5` for support from 4.5 - 6.1
- Use the branch `7-8` for support from 7.0 - 8.7

Expand Down

0 comments on commit 79f22e2

Please sign in to comment.