From 7f3123b61ade87234c140b8fda8f365ef2d75cad Mon Sep 17 00:00:00 2001 From: Philipp Dieter Date: Thu, 28 Nov 2024 15:19:38 +0100 Subject: [PATCH] [TASK] Work on compatibility for TYPO3 11 --- Classes/Controller/ActionController.php | 49 +++++++------ Classes/Controller/TranslationController.php | 7 +- Configuration/TCA/Overrides/tt_content.php | 14 ++++ ext_emconf.php | 1 - ext_localconf.php | 75 +++++++++++++------- 5 files changed, 98 insertions(+), 48 deletions(-) create mode 100644 Configuration/TCA/Overrides/tt_content.php diff --git a/Classes/Controller/ActionController.php b/Classes/Controller/ActionController.php index 02797b6..ab29ca4 100644 --- a/Classes/Controller/ActionController.php +++ b/Classes/Controller/ActionController.php @@ -170,22 +170,6 @@ class ActionController extends BaseController $this->environmentService = $environmentService; } - /** - * propertyMapper - * - * @var PropertyMapper - */ - protected $propertyMapper; - - /** - * @param - */ - public function injectPropertyMapper( - PropertyMapper $propertyMapper - ): void { - $this->propertyMapper = $propertyMapper; - } - /** * propertyMappingConfigurationBuilder * @@ -776,11 +760,36 @@ class ActionController extends BaseController } if ($this->pageType) { if (is_array($this->responseStatus)) { - $this->response->setStatus( - array_key_first($this->responseStatus) - ); + if (version_compare(TYPO3_branch, '10.0', '>=')) { + $response = $this + ->responseFactory + ->createResponse() + ->withHeader( + 'Content-Type', + 'application/json; charset=utf-8' + ) + ->withStatus( + array_key_first($this->responseStatus), + '' + ); + } else { + $this->response->setStatus( + array_key_first($this->responseStatus) + ); + } } else { - $this->response->setStatus($this->responseStatus); + if (version_compare(TYPO3_branch, '10.0', '>=')) { + $response = $this + ->responseFactory + ->createResponse() + ->withHeader( + 'Content-Type', + 'application/json; charset=utf-8' + ) + ->withStatus($this->responseStatus, ''); + } else { + $this->response->setStatus($this->responseStatus); + } } if ($this->pageType == $this->ajaxPageType) { if ($this->environmentService->isEnvironmentInBackendMode()) { diff --git a/Classes/Controller/TranslationController.php b/Classes/Controller/TranslationController.php index bb43ae4..63ea450 100644 --- a/Classes/Controller/TranslationController.php +++ b/Classes/Controller/TranslationController.php @@ -41,9 +41,14 @@ class TranslationController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionCont $languageFactory = GeneralUtility::makeInstance( LocalizationFactory::class ); + $language = $this->request->getAttribute('language'); + $locale = $language->getLocale(); + //\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump( + // $locale, '$locale', 3, true, false + //); $langfileContent = $languageFactory->getParsedData( $langfilePath, - $GLOBALS['LANG']->lang + $locale ); $langfileResult = []; foreach (reset($langfileContent) as $key => $row) { diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php new file mode 100644 index 0000000..c6171a4 --- /dev/null +++ b/Configuration/TCA/Overrides/tt_content.php @@ -0,0 +1,14 @@ + '0.0.1', 'constraints' => [ 'depends' => [ - 'typo3' => '8.7.0-10.99.99', ], 'conflicts' => [], 'suggests' => [], diff --git a/ext_localconf.php b/ext_localconf.php index 55cadcf..c0dc467 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -1,36 +1,59 @@ =')) { - \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( - 'Cjel.TemplatesAide', - 'Dummy', - [ - 'Dummy' => 'list', - 'Translation' => 'translations' - ], - // non-cacheable actions - [ - 'Dummy' => '', - 'Translation' => '' - ] - ); + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( + 'TemplatesAide', + 'Translationplugin', + [ + \Cjel\TemplatesAide\Controller\TranslationController::class => 'translations' + ], + // non-cacheable actions + [ + \Cjel\TemplatesAide\Controller\TranslationController::class => '' + ] + ); - \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( - 'Cjel.TemplatesAide', - 'Translationplugin', - [ - 'Translation' => 'translations' - ], - // non-cacheable actions - [ - 'Dummy' => '', - 'Translation' => '' - ] - ); + } else { + + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( + 'Cjel.TemplatesAide', + 'Dummy', + [ + 'Dummy' => 'list', + 'Translation' => 'translations' + ], + // non-cacheable actions + [ + 'Dummy' => '', + 'Translation' => '' + ] + ); + + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( + 'Cjel.TemplatesAide', + 'Translationplugin', + [ + 'Translation' => 'translations' + ], + // non-cacheable actions + [ + 'Dummy' => '', + 'Translation' => '' + ] + ); + + } // wizards \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig( @@ -119,4 +142,4 @@ call_user_func( } -); \ No newline at end of file +);