[TASK] Move global code from backend.php to BackendController 70/39470/2
authorBenjamin Mack <benni@typo3.org>
Tue, 12 May 2015 03:07:49 +0000 (11:07 +0800)
committerWouter Wolters <typo3@wouterwolters.nl>
Tue, 12 May 2015 07:48:21 +0000 (09:48 +0200)
Resolves: #66901
Releases: master
Change-Id: I5a2540a1ee41c80ebf9e3744e26f24489d6c448f
Reviewed-on: http://review.typo3.org/39470
Reviewed-by: Thomas Schlumberger <thomas@b13.de>
Tested-by: Thomas Schlumberger <thomas@b13.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/backend.php
typo3/sysext/backend/Classes/Controller/BackendController.php

index 4c17926..4d0025a 100644 (file)
@@ -16,31 +16,5 @@ $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_misc.xlf');
 
 // Document generation
 $TYPO3backend = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\BackendController::class);
-// Include extensions which may add css, javascript or toolbar items
-if (is_array($GLOBALS['TYPO3_CONF_VARS']['typo3/backend.php']['additionalBackendItems'])) {
-       foreach ($GLOBALS['TYPO3_CONF_VARS']['typo3/backend.php']['additionalBackendItems'] as $additionalBackendItem) {
-               include_once $additionalBackendItem;
-       }
-}
-
-// Process ExtJS module js and css
-if (is_array($GLOBALS['TBE_MODULES']['_configuration'])) {
-       foreach ($GLOBALS['TBE_MODULES']['_configuration'] as $moduleConfig) {
-               if (is_array($moduleConfig['cssFiles'])) {
-                       foreach ($moduleConfig['cssFiles'] as $cssFileName => $cssFile) {
-                               $files = array(\TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($cssFile));
-                               $files = \TYPO3\CMS\Core\Utility\GeneralUtility::removePrefixPathFromList($files, PATH_site);
-                               $TYPO3backend->addCssFile($cssFileName, '../' . $files[0]);
-                       }
-               }
-               if (is_array($moduleConfig['jsFiles'])) {
-                       foreach ($moduleConfig['jsFiles'] as $jsFile) {
-                               $files = array(\TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($jsFile));
-                               $files = \TYPO3\CMS\Core\Utility\GeneralUtility::removePrefixPathFromList($files, PATH_site);
-                               $TYPO3backend->addJavascriptFile('../' . $files[0]);
-                       }
-               }
-       }
-}
 $TYPO3backend->render();
 \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->shutdown();
index 07ccef2..c59d06e 100644 (file)
@@ -200,6 +200,35 @@ class BackendController {
         * @return void
         */
        public function render() {
+               // Needed for the hooks below, as they previously were located in the global scope
+               // Caution: do not use the global variable anymore but only reference "$this", or use the "renderPreProcess"
+               $GLOBALS['TYPO3backend'] = $TYPO3backend = $this;
+               // Include extensions which may add css, javascript or toolbar items
+               if (is_array($GLOBALS['TYPO3_CONF_VARS']['typo3/backend.php']['additionalBackendItems'])) {
+                       foreach ($GLOBALS['TYPO3_CONF_VARS']['typo3/backend.php']['additionalBackendItems'] as $additionalBackendItem) {
+                               include_once $additionalBackendItem;
+                       }
+               }
+
+               // Process ExtJS module js and css
+               if (is_array($GLOBALS['TBE_MODULES']['_configuration'])) {
+                       foreach ($GLOBALS['TBE_MODULES']['_configuration'] as $moduleConfig) {
+                               if (is_array($moduleConfig['cssFiles'])) {
+                                       foreach ($moduleConfig['cssFiles'] as $cssFileName => $cssFile) {
+                                               $files = array(\TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($cssFile));
+                                               $files = \TYPO3\CMS\Core\Utility\GeneralUtility::removePrefixPathFromList($files, PATH_site);
+                                               $this->addCssFile($cssFileName, '../' . $files[0]);
+                                       }
+                               }
+                               if (is_array($moduleConfig['jsFiles'])) {
+                                       foreach ($moduleConfig['jsFiles'] as $jsFile) {
+                                               $files = array(\TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($jsFile));
+                                               $files = \TYPO3\CMS\Core\Utility\GeneralUtility::removePrefixPathFromList($files, PATH_site);
+                                               $this->addJavascriptFile('../' . $files[0]);
+                                       }
+                               }
+                       }
+               }
                $this->executeHook('renderPreProcess');
 
                // Prepare the scaffolding, at this point extension may still add javascript and css