[TASK] Deprecate insertModuleFunction "$classPath" parameter 62/24462/9
authorErnesto Baschny <ernst@cron-it.de>
Mon, 7 Oct 2013 16:45:32 +0000 (18:45 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Sat, 8 Mar 2014 16:30:53 +0000 (17:30 +0100)
Deprecates the need to specify the $classPath when registering a submodule
with ExtensionManagementUtility::insertModuleFunction. Remove the
parameter's usage throughout the system extensions.

Also re-adds the removed include_once that were removed without proper
deprecation before (see #49992).

Resolves: #52594
Releases: 6.2
Change-Id: I090278b8e2e7a15e05b14dca757ae2b8ef1e5fb4
Reviewed-on: https://review.typo3.org/24462
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
22 files changed:
typo3/sysext/backend/Classes/Module/AbstractFunctionModule.php
typo3/sysext/backend/Classes/Module/BaseScriptClass.php
typo3/sysext/belog/ext_tables.php
typo3/sysext/cms/ext_tables.php
typo3/sysext/core/Classes/Utility/ExtensionManagementUtility.php
typo3/sysext/func/mod1/index.php
typo3/sysext/func_wizards/ext_tables.php
typo3/sysext/indexed_search/Classes/Controller/IndexedPagesController.php
typo3/sysext/indexed_search/Classes/Controller/IndexingStatisticsController.php
typo3/sysext/indexed_search/ext_tables.php
typo3/sysext/indexed_search/modfunc1/class.tx_indexedsearch_modfunc1.php [deleted file]
typo3/sysext/indexed_search/modfunc2/class.tx_indexedsearch_modfunc2.php [deleted file]
typo3/sysext/info/mod1/index.php
typo3/sysext/info_pagetsconfig/ext_tables.php
typo3/sysext/linkvalidator/ext_tables.php
typo3/sysext/recordlist/Classes/RecordList.php
typo3/sysext/recordlist/mod1/index.php
typo3/sysext/recycler/mod1/index.php
typo3/sysext/scheduler/mod1/index.php
typo3/sysext/tstemplate/ext_tables.php
typo3/sysext/wizard_crpages/ext_tables.php
typo3/sysext/wizard_sortpages/ext_tables.php

index aaa2b83..152ae09 100644 (file)
@@ -89,6 +89,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
  * $SOBE->init();
  *
  * Include files?
+ * Note: This "include_once" is deprecated since TYPO3 6.2: use auto-loading instead!
  * foreach($SOBE->include_once as $INC_FILE)   include_once($INC_FILE);
  * $SOBE->checkExtObj();       // Checking for first level external objects
  *
@@ -196,9 +197,10 @@ abstract class AbstractFunctionModule {
        public function init(&$pObj, $conf) {
                $this->pObj = $pObj;
                // Path of this script:
-               $this->thisPath = dirname($conf['path']);
+               $reflector = new \ReflectionObject($this);
+               $this->thisPath = dirname($reflector->getFilename());
                if (!@is_dir($this->thisPath)) {
-                       throw new \RuntimeException('TYPO3 Fatal Error: Extension "' . $this->thisPath . ' was not a directory as expected...', 1270853912);
+                       throw new \RuntimeException('TYPO3 Fatal Error: Could not find path for class ' . get_class($this), 1381164687);
                }
                // Local lang:
                $this->incLocalLang();
@@ -211,6 +213,7 @@ abstract class AbstractFunctionModule {
         *
         * @return void
         * @see $function_key, \TYPO3\CMS\FuncWizards\Controller\WebFunctionWizardsBaseController::init()
+        * @deprecated since 6.2. Instead of this include_once array, extensions should use auto-loading
         * @todo Define visibility
         */
        public function handleExternalFunctionValue() {
index a7eafb3..6798270 100644 (file)
@@ -70,6 +70,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
  *
  * AFTER INIT THE INTERNAL ARRAY ->include_once MAY HOLD FILENAMES TO INCLUDE
  * foreach($SOBE->include_once as $INC_FILE)   include_once($INC_FILE);
+ * Note: This "include_once" is deprecated since TYPO3 6.2: use auto-loading instead!
  *
  * THEN WE WILL CHECK IF THERE IS A 'SUBMODULE' REGISTERED TO BE INITIALIZED AS WELL:
  * $SOBE->checkExtObj();
@@ -180,6 +181,7 @@ class BaseScriptClass {
         * Contains absolute paths to class files to include from the global scope. This is done in the module index.php files after calling the init() function
         *
         * @see handleExternalFunctionValue()
+        * @deprecated since 6.2. Instead of this include_once array, extensions should use auto-loading
         * @todo Define visibility
         */
        public $include_once = array();
@@ -271,6 +273,7 @@ class BaseScriptClass {
         * @param string $MS_value The value-key to fetch from the config array. If NULL (default) MOD_SETTINGS[$MM_key] will be used. This is useful if you want to force another function than the one defined in MOD_SETTINGS[function]. Call this in init() function of your Script Class: handleExternalFunctionValue('function', $forcedSubModKey)
         * @return void
         * @see getExternalItemConfig(), $include_once, init()
+        * @deprecated since 6.2. Instead of this include_once array, extensions should use auto-loading
         * @todo Define visibility
         */
        public function handleExternalFunctionValue($MM_key = 'function', $MS_value = NULL) {
index 019b4e9..4a8389a 100644 (file)
@@ -9,7 +9,7 @@ if (TYPO3_MODE === 'BE' && !(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_INSTALL)) {
        \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::insertModuleFunction(
                'web_info',
                'TYPO3\\CMS\\Belog\\Module\\BackendLogModuleBootstrap',
-               \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'Classes/Module/BackendLogModuleBootstrap.php',
+               NULL,
                'Log'
        );
 
index f1deafd..707063c 100644 (file)
@@ -6,8 +6,8 @@ if (TYPO3_MODE == 'BE') {
        \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModule('web', 'layout', 'top', \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'layout/');
        \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr('_MOD_web_layout', 'EXT:cms/locallang_csh_weblayout.xlf');
        \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr('_MOD_web_info', 'EXT:cms/locallang_csh_webinfo.xlf');
-       \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::insertModuleFunction('web_info', 'tx_cms_webinfo_page', \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'web_info/class.tx_cms_webinfo.php', 'LLL:EXT:cms/locallang_tca.xlf:mod_tx_cms_webinfo_page');
-       \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::insertModuleFunction('web_info', 'tx_cms_webinfo_lang', \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'web_info/class.tx_cms_webinfo_lang.php', 'LLL:EXT:cms/locallang_tca.xlf:mod_tx_cms_webinfo_lang');
+       \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::insertModuleFunction('web_info', 'tx_cms_webinfo_page', NULL, 'LLL:EXT:cms/locallang_tca.xlf:mod_tx_cms_webinfo_page');
+       \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::insertModuleFunction('web_info', 'tx_cms_webinfo_lang', NULL, 'LLL:EXT:cms/locallang_tca.xlf:mod_tx_cms_webinfo_lang');
 }
 // Add allowed records to pages:
 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('pages_language_overlay,tt_content,sys_template,sys_domain,backend_layout');
index 91b4238..29c0267 100644 (file)
@@ -934,7 +934,7 @@ class ExtensionManagementUtility {
         *
         * @param string $modname Module name
         * @param string $className Class name
-        * @param string $classPath Class path
+        * @param string $classPath Class path, deprecated since 6.2, use auto-loading instead
         * @param string $title Title of module
         * @param string $MM_key Menu array key - default is "function
         * @param string $WS Workspace conditions. Blank means all workspaces, any other string can be a comma list of "online", "offline" and "custom
@@ -942,6 +942,14 @@ class ExtensionManagementUtility {
         * @see \TYPO3\CMS\Backend\Module\BaseScriptClass::mergeExternalItems()
         */
        static public function insertModuleFunction($modname, $className, $classPath, $title, $MM_key = 'function', $WS = '') {
+               if (!empty($classPath)) {
+                       GeneralUtility::deprecationLog(
+                               sprintf('insertModuleFunction(%s, %s, ...): Use auto-loading for the class and pass NULL as $classPath since 6.2.',
+                                       $modname,
+                                       $className
+                               )
+                       );
+               }
                $GLOBALS['TBE_MODULES_EXT'][$modname]['MOD_MENU'][$MM_key][$className] = array(
                        'name' => $className,
                        'path' => $classPath,
index 1309cac..782b5fa 100644 (file)
 $SOBE = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Func\\Controller\\PageFunctionsController');
 $SOBE->init();
 // Include files?
+// @deprecated since 6.2 (see ExtensionManagementUtility::insertModuleFunction)
 foreach ($SOBE->include_once as $INC_FILE) {
        include_once $INC_FILE;
 }
 // Checking for first level external objects
 $SOBE->checkExtObj();
 // Repeat Include files! - if any files has been added by second-level extensions
+// @deprecated since 6.2 (see ExtensionManagementUtility::insertModuleFunction)
 foreach ($SOBE->include_once as $INC_FILE) {
        include_once $INC_FILE;
 }
index 58c3d97..f8ac565 100644 (file)
@@ -6,7 +6,7 @@ if (TYPO3_MODE === 'BE') {
        \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::insertModuleFunction(
                'web_func',
                'TYPO3\\CMS\\FuncWizards\\Controller\\WebFunctionWizardsBaseController',
-               \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'Classes/Controller/WebFunctionWizardsBaseController.php',
+               NULL,
                'LLL:EXT:func_wizards/locallang.xlf:mod_wizards'
        );
        \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr('_MOD_web_func', 'EXT:func_wizards/locallang_csh.xlf');
index 3435d1e..d1eba35 100644 (file)
@@ -78,6 +78,13 @@ class IndexedPagesController extends \TYPO3\CMS\Backend\Module\AbstractFunctionM
        protected $maxListPerPage;
 
        /**
+        * Default constructor loads additional locallang
+        */
+       public function __construct() {
+               $GLOBALS['LANG']->includeLLFile('EXT:indexed_search/modfunc1/locallang.xlf');
+       }
+
+       /**
         * Initialize menu array internally
         *
         * @return      void
index d539bb0..95ffe4c 100644 (file)
@@ -32,6 +32,13 @@ namespace TYPO3\CMS\IndexedSearch\Controller;
 class IndexingStatisticsController extends \TYPO3\CMS\Backend\Module\AbstractFunctionModule {
 
        /**
+        * Default constructor loads additional locallang
+        */
+       public function __construct() {
+               $GLOBALS['LANG']->includeLLFile('EXT:indexed_search/modfunc2/locallang.xlf');
+       }
+
+       /**
         * Calls showStats to generate output.
         *
         * @return      string          html table with results from showStats()
index 0a8367e..f0357b8 100644 (file)
@@ -13,8 +13,8 @@ if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('extbase')) {
 }
 if (TYPO3_MODE == 'BE') {
        \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModule('tools', 'isearch', 'after:log', \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'mod/');
-       \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::insertModuleFunction('web_info', 'TYPO3\\CMS\\IndexedSearch\\Controller\\IndexedPagesController', \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'modfunc1/class.tx_indexedsearch_modfunc1.php', 'LLL:EXT:indexed_search/locallang.xlf:mod_indexed_search');
-       \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::insertModuleFunction('web_info', 'TYPO3\\CMS\\IndexedSearch\\Controller\\IndexingStatisticsController', \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'modfunc2/class.tx_indexedsearch_modfunc2.php', 'LLL:EXT:indexed_search/locallang.xlf:mod2_indexed_search');
+       \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::insertModuleFunction('web_info', 'TYPO3\\CMS\\IndexedSearch\\Controller\\IndexedPagesController', NULL, 'LLL:EXT:indexed_search/locallang.xlf:mod_indexed_search');
+       \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::insertModuleFunction('web_info', 'TYPO3\\CMS\\IndexedSearch\\Controller\\IndexingStatisticsController', NULL, 'LLL:EXT:indexed_search/locallang.xlf:mod2_indexed_search');
 }
 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('index_config');
 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr('index_config', 'EXT:indexed_search/locallang_csh_indexcfg.xlf');
diff --git a/typo3/sysext/indexed_search/modfunc1/class.tx_indexedsearch_modfunc1.php b/typo3/sysext/indexed_search/modfunc1/class.tx_indexedsearch_modfunc1.php
deleted file mode 100644 (file)
index 9e71e02..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<?php
-/**
- * This file is empty by intention: At the moment, it is still needed by
- * TYPO3\CMS\Backend\Module\AbstractFunctionModule and registered as 'path'
- * in ext_tables.php insertModuleFunction(). See init() method of AbstractFunctionModule
- * to improve this.
- *
- * As real class TYPO3\CMS\IndexedSearch\Controller\IndexedPagesController is called.
- */
diff --git a/typo3/sysext/indexed_search/modfunc2/class.tx_indexedsearch_modfunc2.php b/typo3/sysext/indexed_search/modfunc2/class.tx_indexedsearch_modfunc2.php
deleted file mode 100644 (file)
index 4e79fb1..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<?php
-/**
- * This file is empty by intention: At the moment, it is still needed by
- * TYPO3\CMS\Backend\Module\AbstractFunctionModule and registered as 'path'
- * in ext_tables.php insertModuleFunction(). See init() method of AbstractFunctionModule
- * to improve this.
- *
- * As real class TYPO3\CMS\IndexedSearch\Controller\IndexingStatisticsController is called.
- */
index 4b5039e..85704c6 100644 (file)
  */
 $SOBE = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Info\\Controller\\InfoModuleController');
 $SOBE->init();
+// Include files?
+// @deprecated since 6.2 (see ExtensionManagementUtility::insertModuleFunction)
+foreach ($SOBE->include_once as $INC_FILE) {
+       include_once $INC_FILE;
+}
 // Checking for first level external objects
 $SOBE->checkExtObj();
+// Repeat Include files! - if any files has been added by second-level extensions
+// @deprecated since 6.2 (see ExtensionManagementUtility::insertModuleFunction)
+foreach ($SOBE->include_once as $INC_FILE) {
+       include_once $INC_FILE;
+}
 // Checking second level external objects
 $SOBE->checkSubExtObj();
 $SOBE->main();
index 7b57b1c..94182db 100644 (file)
@@ -6,7 +6,7 @@ if (TYPO3_MODE === 'BE') {
        \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::insertModuleFunction(
                'web_info',
                'TYPO3\CMS\InfoPagetsconfig\Controller\InfoPageTyposcriptConfigController',
-               \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'Classes/InfoPageTyposcriptConfigController.php',
+               NULL,
                'LLL:EXT:info_pagetsconfig/locallang.xlf:mod_pagetsconfig'
        );
 }
index 107fa57..3b40c93 100644 (file)
@@ -7,7 +7,7 @@ if (TYPO3_MODE === 'BE') {
        \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::insertModuleFunction(
                'web_info',
                'TYPO3\\CMS\\Linkvalidator\\Report\\LinkValidatorReport',
-               \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('linkvalidator') . 'Classes/Report/LinkValidatorReport.php',
+               NULL,
                'LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:mod_linkvalidator'
        );
 }
index 464f2af..6a1f882 100644 (file)
@@ -150,12 +150,6 @@ class RecordList {
         */
        public $MOD_SETTINGS = array();
 
-       // Array, where files to include is accumulated in the init() function
-       /**
-        * @todo Define visibility
-        */
-       public $include_once = array();
-
        // Internal, dynamic:
        // Module output accumulation
        /**
index d4e3da1..93a873d 100644 (file)
 
 $SOBE = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Recordlist\\RecordList');
 $SOBE->init();
-// Include files?
-foreach ($SOBE->include_once as $INC_FILE) {
-       include_once $INC_FILE;
-}
 $SOBE->clearCache();
 $SOBE->main();
 $SOBE->printContent();
index 51fa093..9cf85a0 100644 (file)
@@ -33,6 +33,7 @@ require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('recycl
 $SOBE = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Recycler\\Controller\\RecyclerModuleController');
 $SOBE->initialize();
 // Include files?
+// @deprecated since 6.2 (see ExtensionManagementUtility::insertModuleFunction)
 foreach ($SOBE->include_once as $INC_FILE) {
        include_once $INC_FILE;
 }
index cc3a7ee..4f49b7b 100644 (file)
@@ -30,6 +30,7 @@ $BE_USER->modAccess($MCONF, 1);
 $SOBE = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Scheduler\\Controller\\SchedulerModuleController');
 $SOBE->init();
 // Include files?
+// @deprecated since 6.2 (see ExtensionManagementUtility::insertModuleFunction)
 foreach ($SOBE->include_once as $INC_FILE) {
        include_once $INC_FILE;
 }
index 8f4b38c..b79dc81 100644 (file)
@@ -16,29 +16,29 @@ if (TYPO3_MODE === 'BE') {
        \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::insertModuleFunction(
                'web_ts',
                'TYPO3\\CMS\\Tstemplate\\Controller\\TypoScriptTemplateConstantEditorModuleFunctionController',
-               $extensionPath . 'Classes/Controller/TypoScriptTemplateConstantEditorModuleFunctionController.php',
+               NULL,
                'LLL:EXT:tstemplate/ts/locallang.xlf:constantEditor'
        );
 
        \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::insertModuleFunction(
                'web_ts',
                'TYPO3\\CMS\\Tstemplate\\Controller\\TypoScriptTemplateInformationModuleFunctionController',
-               $extensionPath . 'Classes/Controller/TypoScriptTemplateInformationModuleFunctionController.php',
+               NULL,
                'LLL:EXT:tstemplate/ts/locallang.xlf:infoModify'
        );
 
        \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::insertModuleFunction(
                'web_ts',
                'TYPO3\\CMS\\Tstemplate\\Controller\\TypoScriptTemplateObjectBrowserModuleFunctionController',
-               $extensionPath  . 'Classes/Controller/TypoScriptTemplateObjectBrowserModuleFunctionController.php',
+               NULL,
                'LLL:EXT:tstemplate/ts/locallang.xlf:objectBrowser'
        );
 
        \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::insertModuleFunction(
                'web_ts',
                'TYPO3\\CMS\\Tstemplate\\Controller\\TemplateAnalyzerModuleFunctionController',
-               $extensionPath . 'Classes/Controller/TemplateAnalyzerModuleFunctionController.php',
+               NULL,
                'LLL:EXT:tstemplate/ts/locallang.xlf:templateAnalyzer'
        );
 
-}
+}
\ No newline at end of file
index 4732ebf..dc6579d 100644 (file)
@@ -6,7 +6,7 @@ if (TYPO3_MODE === 'BE') {
        \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::insertModuleFunction(
                'web_func',
                'TYPO3\\CMS\\WizardCrpages\\Controller\\CreatePagesWizardModuleFunctionController',
-               \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'Classes/Controller/CreatePagesWizardModuleFunctionController.php',
+               NULL,
                'LLL:EXT:wizard_crpages/locallang.xlf:wiz_crMany',
                'wiz'
        );
index 455b0a0..622a7ac 100644 (file)
@@ -5,8 +5,8 @@ if (!defined('TYPO3_MODE')) {
 if (TYPO3_MODE === 'BE') {
        \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::insertModuleFunction(
                'web_func',
-               'TYPO3\\CMS\\WizardSortPages\\View\\SortPagesWizardModuleFunction',
-               \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'Classes/View/SortPagesWizardModuleFunction.php',
+               'TYPO3\\CMS\\WizardSortpages\\View\\SortPagesWizardModuleFunction',
+               NULL,
                'LLL:EXT:wizard_sortpages/locallang.xlf:wiz_sort',
                'wiz'
        );