‪TYPO3CMS  10.4
LoadTcaService.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
20 use TYPO3\CMS\Core\Package\PackageManager;
21 
27 {
31  private ‪$lateBootService;
32 
34  {
35  $this->lateBootService = ‪$lateBootService;
36  }
37 
48  {
49  $container = $this->lateBootService->getContainer();
50  $backup = $this->lateBootService->makeCurrent($container);
51 
52  ‪$GLOBALS['TCA'] = [];
53 
54  $activePackages = $container->get(PackageManager::class)->getActivePackages();
55 
56  // First load "full table" files from Configuration/TCA
57  foreach ($activePackages as $package) {
58  $tcaConfigurationDirectory = $package->getPackagePath() . 'Configuration/TCA';
59  if (is_dir($tcaConfigurationDirectory)) {
60  $files = scandir($tcaConfigurationDirectory);
61  foreach ($files as $file) {
62  if (is_file($tcaConfigurationDirectory . '/' . $file)
63  && ($file !== '.')
64  && ($file !== '..')
65  && (substr($file, -4, 4) === '.php')
66  ) {
67  $tcaOfTable = require $tcaConfigurationDirectory . '/' . $file;
68  if (is_array($tcaOfTable)) {
69  // TCA table name is filename without .php suffix, eg 'sys_notes', not 'sys_notes.php'
70  $tcaTableName = substr($file, 0, -4);
71  ‪$GLOBALS['TCA'][$tcaTableName] = $tcaOfTable;
72  }
73  }
74  }
75  }
76  }
77 
78  // Apply category stuff
80 
81  // Execute override files from Configuration/TCA/Overrides
82  foreach ($activePackages as $package) {
83  $tcaOverridesPathForPackage = $package->getPackagePath() . 'Configuration/TCA/Overrides';
84  if (is_dir($tcaOverridesPathForPackage)) {
85  $files = scandir($tcaOverridesPathForPackage);
86  foreach ($files as $file) {
87  if (is_file($tcaOverridesPathForPackage . '/' . $file)
88  && ($file !== '.')
89  && ($file !== '..')
90  && (substr($file, -4, 4) === '.php')
91  ) {
92  require $tcaOverridesPathForPackage . '/' . $file;
93  }
94  }
95  }
96  }
97 
98  $this->lateBootService->makeCurrent(null, $backup);
99  }
100 
106  public function ‪loadSingleExtTablesFile(string $extensionKey)
107  {
108  $container = $this->lateBootService->getContainer();
109  $backup = $this->lateBootService->makeCurrent($container);
110 
111  $packageManager = $container->get(PackageManager::class);
112  try {
113  $package = $packageManager->getPackage($extensionKey);
114  } catch (UnknownPackageException $e) {
115  throw new \RuntimeException(
116  'Extension ' . $extensionKey . ' is not active',
117  1477217619
118  );
119  }
120 
121  $extTablesPath = $package->getPackagePath() . 'ext_tables.php';
122  // Load ext_tables.php file of the extension
123  if (@file_exists($extTablesPath)) {
124  require $extTablesPath;
125  }
126 
127  $this->lateBootService->makeCurrent(null, $backup);
128  }
129 }
‪TYPO3\CMS\Core\Package\Exception\UnknownPackageException
Definition: UnknownPackageException.php:24
‪TYPO3\CMS\Install\Service\LoadTcaService\loadSingleExtTablesFile
‪loadSingleExtTablesFile(string $extensionKey)
Definition: LoadTcaService.php:105
‪TYPO3\CMS\Install\Service\LoadTcaService\$lateBootService
‪LateBootService $lateBootService
Definition: LoadTcaService.php:30
‪TYPO3\CMS\Install\Service\LoadTcaService\loadExtensionTablesWithoutMigration
‪loadExtensionTablesWithoutMigration()
Definition: LoadTcaService.php:46
‪TYPO3\CMS\Core\Category\CategoryRegistry\getInstance
‪static CategoryRegistry getInstance()
Definition: CategoryRegistry.php:52
‪TYPO3\CMS\Core\Category\CategoryRegistry
Definition: CategoryRegistry.php:29
‪TYPO3\CMS\Install\Service\LoadTcaService\__construct
‪__construct(LateBootService $lateBootService)
Definition: LoadTcaService.php:32
‪TYPO3\CMS\Install\Service\LateBootService
Definition: LateBootService.php:34
‪TYPO3\CMS\Install\Service\LoadTcaService
Definition: LoadTcaService.php:27
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Category\CategoryRegistry\applyTcaForPreRegisteredTables
‪applyTcaForPreRegisteredTables()
Definition: CategoryRegistry.php:215
‪TYPO3\CMS\Install\Service
Definition: ClearCacheService.php:16