TYPO3 CMS  TYPO3_8-7
LoadTcaService.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
20 
25 {
36  {
37  $GLOBALS['TCA'] = [];
38 
39  $activePackages = GeneralUtility::makeInstance(PackageManager::class)->getActivePackages();
40 
41  // First load "full table" files from Configuration/TCA
42  foreach ($activePackages as $package) {
43  $tcaConfigurationDirectory = $package->getPackagePath() . 'Configuration/TCA';
44  if (is_dir($tcaConfigurationDirectory)) {
45  $files = scandir($tcaConfigurationDirectory);
46  foreach ($files as $file) {
47  if (is_file($tcaConfigurationDirectory . '/' . $file)
48  && ($file !== '.')
49  && ($file !== '..')
50  && (substr($file, -4, 4) === '.php')
51  ) {
52  $tcaOfTable = require $tcaConfigurationDirectory . '/' . $file;
53  if (is_array($tcaOfTable)) {
54  // TCA table name is filename without .php suffix, eg 'sys_notes', not 'sys_notes.php'
55  $tcaTableName = substr($file, 0, -4);
56  $GLOBALS['TCA'][$tcaTableName] = $tcaOfTable;
57  }
58  }
59  }
60  }
61  }
62 
63  // Apply category stuff
64  CategoryRegistry::getInstance()->applyTcaForPreRegisteredTables();
65 
66  // Execute override files from Configuration/TCA/Overrides
67  foreach ($activePackages as $package) {
68  $tcaOverridesPathForPackage = $package->getPackagePath() . 'Configuration/TCA/Overrides';
69  if (is_dir($tcaOverridesPathForPackage)) {
70  $files = scandir($tcaOverridesPathForPackage);
71  foreach ($files as $file) {
72  if (is_file($tcaOverridesPathForPackage . '/' . $file)
73  && ($file !== '.')
74  && ($file !== '..')
75  && (substr($file, -4, 4) === '.php')
76  ) {
77  require $tcaOverridesPathForPackage . '/' . $file;
78  }
79  }
80  }
81  }
82  }
83 
89  public function loadSingleExtTablesFile(string $extensionKey)
90  {
91  global $T3_SERVICES, $T3_VAR, $TYPO3_CONF_VARS;
92  global $TBE_MODULES, $TBE_MODULES_EXT, $TCA;
93  global $PAGES_TYPES, $TBE_STYLES;
94  global $_EXTKEY;
95 
96  if (!isset($GLOBALS['TYPO3_LOADED_EXT'][$extensionKey])) {
97  throw new \RuntimeException(
98  'Extension ' . $extensionKey . ' does not exist in TYPO3_LOADED_EXT',
99  1477217619
100  );
101  }
102 
103  $extensionInformation = $GLOBALS['TYPO3_LOADED_EXT'][$extensionKey];
104  $_EXTKEY = $extensionKey;
105  // Load each ext_tables.php file of loaded extensions
106  if ((is_array($extensionInformation) || $extensionInformation instanceof \ArrayAccess)
107  && $extensionInformation['ext_tables.php']
108  ) {
109  // $_EXTKEY and $_EXTCONF are available in ext_tables.php
110  // and are explicitly set in cached file as well
111  $_EXTCONF = $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$_EXTKEY] ?? null;
112  require $extensionInformation['ext_tables.php'];
113  }
114  }
115 }
loadSingleExtTablesFile(string $extensionKey)
static makeInstance($className,... $constructorArguments)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']