[FEATURE][API] Add PostProcessing Hook after inclusion of extTables
authorSteffen Ritter <info@rs-websystems.de>
Sun, 6 Nov 2011 13:53:09 +0000 (14:53 +0100)
committerSteffen Ritter <info@rs-websystems.de>
Sun, 18 Dec 2011 10:11:59 +0000 (11:11 +0100)
For modifiying the TCA of all Tables, you need to have an entry point
somewhere, shortly after all TCA definitions (which sould be within
ext_tables.php of each extension) are included.

To solve this problem a hook is introduced which allows to e.g. modify
all TCA tables in comparison to the classic way, where extensions are
only featured to modify TCA of extensions which had been loaded before.

Change-Id: Icd9653fccb477385f4c7107bdea637f6720c3d69
Resolves: #31615
Releases: 4.7
Reviewed-on: http://review.typo3.org/6564
Reviewed-by: Oliver Hader
Tested-by: Oliver Hader
Reviewed-by: Dominik Mathern
Tested-by: Dominik Mathern
Reviewed-by: Steffen Ritter
Tested-by: Steffen Ritter
t3lib/core_autoload.php
t3lib/interfaces/interface.t3lib_exttables_postprocessinghook.php [new file with mode: 0644]
typo3/init.php
typo3/sysext/cms/tslib/class.tslib_fe.php
typo3/sysext/install/mod/class.tx_install.php
typo3/sysext/install/updates/class.tx_coreupdates_migrateworkspaces.php

index 883285c..d4c2012 100644 (file)
@@ -233,6 +233,7 @@ $t3libClasses = array(
        't3lib_tree_pagetree_indicatorprovider' => PATH_t3lib . 'tree/pagetree/interfaces/interface.t3lib_tree_pagetree_interfaces_indicatorprovider.php',
        't3lib_tree_pagetree_interfaces_collectionprocessor' => PATH_t3lib . 'tree/pagetree/interfaces/interface.t3lib_tree_pagetree_interfaces_collectionprocessor.php',
        't3lib_http_request' => PATH_t3lib . 'http/class.t3lib_http_request.php',
+       't3lib_exttables_postprocessinghook'=> PATH_t3lib . 'interfaces/interface.t3lib_exttables_postprocessinghook.php',
 );
 
 $tslibClasses = require(PATH_typo3 . 'sysext/cms/ext_autoload.php');
diff --git a/t3lib/interfaces/interface.t3lib_exttables_postprocessinghook.php b/t3lib/interfaces/interface.t3lib_exttables_postprocessinghook.php
new file mode 100644 (file)
index 0000000..450a31b
--- /dev/null
@@ -0,0 +1,48 @@
+<?php
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2011 Steffen Ritter <steffen.ritter@typo3.org>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *  A copy is found in the textfile GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+
+/**
+ * interface for classes with hook for postprocessing extTables after loading
+ *
+ * @author Steffen Ritter <steffen.ritter@typo3.org>
+ * @package TYPO3
+ * @subpackage t3lib
+ */
+interface t3lib_extTables_PostProcessingHook {
+
+       /**
+        * Function which may process data created / registered by extTables
+        * scripts (f.e. modifying TCA data of all extensions)
+        *
+        * @return void
+        */
+       public function processData();
+
+}
+
+?>
\ No newline at end of file
index ba586b7..cad7f9f 100644 (file)
@@ -383,6 +383,18 @@ if (TYPO3_extTableDef_script)      {
        include (PATH_typo3conf.TYPO3_extTableDef_script);
 }
 
+       // Hook for postprocessing values set in extTables.php
+if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'])) {
+       foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'] as $_classRef) {
+               $hookObject = t3lib_div::getUserObj($_classRef);
+               if (!$hookObject instanceof t3lib_extTables_PostProcessingHook) {
+                       throw new UnexpectedValueException('$hookObject must implement interface t3lib_extTables_PostProcessingHook', 1320585902);
+               }
+               $hookObject->processData();
+       }
+}
+
+
        // load TYPO3 SpriteGenerating API
 $spriteManager = t3lib_div::makeInstance('t3lib_SpriteManager', TRUE);
 $spriteManager->loadCacheFile();
index b05628d..9ce8101 100644 (file)
                        }
 
                        $this->TCAloaded = $TCAloaded;
+
+                               // Hook for postprocessing values set in extTables.php
+                       if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'])) {
+                               foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'] AS $_classRef) {
+                                       $hookObject = t3lib_div::getUserObj($_classRef);
+                                       if (!$hookObject instanceof t3lib_extTables_PostProcessingHook) {
+                                               throw new UnexpectedValueException('$hookObject must implement interface t3lib_extTables_PostProcessingHook', 1320585902);
+                                       }
+                                       $hookObject->processData();
+                               }
+                       }
                }
        }
 
@@ -4796,4 +4807,4 @@ if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLA
        include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['tslib/class.tslib_fe.php']);
 }
 
-?>
\ No newline at end of file
+?>
index f6e7cb4..3a4fff0 100644 (file)
@@ -7500,6 +7500,19 @@ $out="
                foreach ($GLOBALS['TCA'] as $table => $conf) {
                        t3lib_div::loadTCA($table);
                }
+
+
+                       // Hook for postprocessing values set in extTables.php
+               if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'])) {
+                       foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'] AS $_classRef) {
+                               $hookObject = t3lib_div::getUserObj($_classRef);
+                               if (!$hookObject instanceof t3lib_extTables_PostProcessingHook) {
+                                       throw new UnexpectedValueException('$hookObject must implement interface t3lib_extTables_PostProcessingHook', 1320585902);
+                               }
+                               $hookObject->processData();
+                       }
+               }
+
        }
 
 
index b66eec9..bdcf05f 100644 (file)
@@ -386,6 +386,18 @@ class tx_coreupdates_migrateworkspaces extends tx_coreupdates_installsysexts {
                } else {
                        include_once(PATH_t3lib . 'stddb/load_ext_tables.php');
                }
+
+
+                       // Hook for postprocessing values set in extTables.php
+               if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'])) {
+                       foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'] AS $_classRef) {
+                               $hookObject = t3lib_div::getUserObj($_classRef);
+                               if (!$hookObject instanceof t3lib_extTables_PostProcessingHook) {
+                                       throw new UnexpectedValueException('$hookObject must implement interface t3lib_extTables_PostProcessingHook', 1320585902);
+                               }
+                               $hookObject->processData();
+                       }
+               }
        }
 
        /**