‪TYPO3CMS  9.5
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 
18 use TYPO3\CMS\Core\Package\PackageManager;
20 
26 {
37  {
38  ‪$GLOBALS['TCA'] = [];
39 
40  $activePackages = GeneralUtility::makeInstance(PackageManager::class)->getActivePackages();
41 
42  // First load "full table" files from Configuration/TCA
43  foreach ($activePackages as $package) {
44  $tcaConfigurationDirectory = $package->getPackagePath() . 'Configuration/TCA';
45  if (is_dir($tcaConfigurationDirectory)) {
46  $files = scandir($tcaConfigurationDirectory);
47  foreach ($files as $file) {
48  if (is_file($tcaConfigurationDirectory . '/' . $file)
49  && ($file !== '.')
50  && ($file !== '..')
51  && (substr($file, -4, 4) === '.php')
52  ) {
53  $tcaOfTable = require $tcaConfigurationDirectory . '/' . $file;
54  if (is_array($tcaOfTable)) {
55  // TCA table name is filename without .php suffix, eg 'sys_notes', not 'sys_notes.php'
56  $tcaTableName = substr($file, 0, -4);
57  ‪$GLOBALS['TCA'][$tcaTableName] = $tcaOfTable;
58  }
59  }
60  }
61  }
62  }
63 
64  // Apply category stuff
66 
67  // Execute override files from Configuration/TCA/Overrides
68  foreach ($activePackages as $package) {
69  $tcaOverridesPathForPackage = $package->getPackagePath() . 'Configuration/TCA/Overrides';
70  if (is_dir($tcaOverridesPathForPackage)) {
71  $files = scandir($tcaOverridesPathForPackage);
72  foreach ($files as $file) {
73  if (is_file($tcaOverridesPathForPackage . '/' . $file)
74  && ($file !== '.')
75  && ($file !== '..')
76  && (substr($file, -4, 4) === '.php')
77  ) {
78  require $tcaOverridesPathForPackage . '/' . $file;
79  }
80  }
81  }
82  }
83  }
84 
90  public function ‪loadSingleExtTablesFile(string $extensionKey)
91  {
92  global $T3_SERVICES, $T3_VAR, $TYPO3_CONF_VARS;
93  global $TBE_MODULES, $TBE_MODULES_EXT, $TCA;
94  global $PAGES_TYPES, $TBE_STYLES;
95  global $_EXTKEY;
96 
97  $packageManager = GeneralUtility::makeInstance(PackageManager::class);
98  try {
99  $package = $packageManager->getPackage($extensionKey);
100  } catch (\‪TYPO3\CMS\Core\Package\‪Exception\UnknownPackageException $e) {
101  throw new \RuntimeException(
102  'Extension ' . $extensionKey . ' is not active',
103  1477217619
104  );
105  }
106 
107  $extTablesPath = $package->getPackagePath() . 'ext_tables.php';
108  // Load ext_tables.php file of the extension
109  if (@file_exists($extTablesPath)) {
110  // $_EXTKEY and $_EXTCONF are available in ext_tables.php
111  // and are explicitly set in cached file as well
112  $_EXTKEY = $extensionKey;
113  $_EXTCONF = ‪$GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$_EXTKEY] ?? null;
114  require $extTablesPath;
115  }
116  }
117 }
‪TYPO3\CMS\Install\Service\LoadTcaService\loadSingleExtTablesFile
‪loadSingleExtTablesFile(string $extensionKey)
Definition: LoadTcaService.php:90
‪TYPO3
‪TYPO3\CMS\Install\Service\LoadTcaService\loadExtensionTablesWithoutMigration
‪loadExtensionTablesWithoutMigration()
Definition: LoadTcaService.php:36
‪TYPO3\CMS\Core\Category\CategoryRegistry\getInstance
‪static CategoryRegistry getInstance()
Definition: CategoryRegistry.php:50
‪TYPO3\CMS\Core\Category\CategoryRegistry
Definition: CategoryRegistry.php:27
‪TYPO3\CMS\Install\Service\LoadTcaService
Definition: LoadTcaService.php:26
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Category\CategoryRegistry\applyTcaForPreRegisteredTables
‪applyTcaForPreRegisteredTables()
Definition: CategoryRegistry.php:223
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Install\Service
Definition: ClearCacheService.php:2
‪TYPO3\CMS\Install\Service\Exception
Definition: Exception.php:21