From 1a6b238b1c076b4139701a21797f9db248d38fdd Mon Sep 17 00:00:00 2001 From: Claus Due Date: Sun, 12 Mar 2017 14:26:22 +0100 Subject: [PATCH] [TASK] Resolve cross dep between EXT:backend and EXT:feedit This patch moves frontend-editing intialisation from the EditDocumentController (EXT:backend) to a signal listener in EXT:feedit. Step towards extracting EXT:feedit to TER. Change-Id: I09a7e5a2205e7020e7145023d7d63c61d9be508c Resolves: #80244 Releases: master Reviewed-on: https://review.typo3.org/52011 Tested-by: TYPO3com Reviewed-by: Tymoteusz Motylewski Reviewed-by: Christian Kuhn Tested-by: Christian Kuhn Reviewed-by: Georg Ringer Tested-by: Georg Ringer --- Classes/FrontendEditAssetLoader.php | 65 +++++++++++++++++++++++++++++ ext_localconf.php | 9 ++++ 2 files changed, 74 insertions(+) create mode 100644 Classes/FrontendEditAssetLoader.php diff --git a/Classes/FrontendEditAssetLoader.php b/Classes/FrontendEditAssetLoader.php new file mode 100644 index 0000000..1d4a889 --- /dev/null +++ b/Classes/FrontendEditAssetLoader.php @@ -0,0 +1,65 @@ +getLanguageService(); + $coreLabels = [ + 'csh_tooltip_loading' => $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:csh_tooltip_loading') + ]; + $generatedLabels = []; + $generatedLabels['core'] = $coreLabels; + $code = 'TYPO3.LLL = ' . json_encode($generatedLabels) . ';'; + $filePath = 'typo3temp/assets/js/backend-' . sha1($code) . '.js'; + if (!file_exists(PATH_site . $filePath)) { + // writeFileToTypo3tempDir() returns NULL on success (please double-read!) + $error = GeneralUtility::writeFileToTypo3tempDir(PATH_site . $filePath, $code); + if ($error !== null) { + throw new \RuntimeException('Locallang JS file could not be written to ' . $filePath . '. Reason: ' . $error, 1446118286); + } + } + $pageRenderer->addJsFile('../' . $filePath); + } + } + + /** + * Returns LanguageService + * + * @return \TYPO3\CMS\Lang\LanguageService + */ + protected function getLanguageService() + { + return $GLOBALS['LANG']; + } +} diff --git a/ext_localconf.php b/ext_localconf.php index 943ffcd..b356fa8 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -3,3 +3,12 @@ defined('TYPO3_MODE') or die(); // Register the edit panel view. $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/classes/class.frontendedit.php']['edit'] = \TYPO3\CMS\Feedit\FrontendEditPanel::class; + +if (TYPO3_MODE === 'FE') { + \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class)->connect( + \TYPO3\CMS\Backend\Controller\EditDocumentController::class, + 'initAfter', + \TYPO3\CMS\Feedit\FrontendEditAssetLoader::class, + 'attachAssets' + ); +}