‪TYPO3CMS  ‪main
SiteTcaConfiguration.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Symfony\Component\Finder\Finder;
22 use TYPO3\CMS\Core\Package\PackageManager;
24 
34 {
43  public function ‪getTca(): array
44  {
45  ‪$GLOBALS['SiteConfiguration'] = [];
46  $activePackages = GeneralUtility::makeInstance(PackageManager::class)->getActivePackages();
47  // First load "full table" files from Configuration/SiteConfiguration
48  ‪$finder = (new Finder())->files()->depth(0)->name('*.php');
49  $hasDirectoryEntries = false;
50  foreach ($activePackages as $package) {
51  try {
52  ‪$finder->in($package->getPackagePath() . 'Configuration/SiteConfiguration');
53  } catch (\InvalidArgumentException $e) {
54  // No such directory in this package
55  continue;
56  }
57  $hasDirectoryEntries = true;
58  }
59  if ($hasDirectoryEntries) {
60  foreach (‪$finder as $fileInfo) {
61  ‪$GLOBALS['SiteConfiguration'][substr($fileInfo->getBasename(), 0, -4)] = require $fileInfo->getPathname();
62  }
63  }
64  // Execute override files from Configuration/SiteConfiguration/Overrides
65  ‪$finder = (new Finder())->files()->depth(0)->name('*.php');
66  $hasDirectoryEntries = false;
67  foreach ($activePackages as $package) {
68  try {
69  ‪$finder->in($package->getPackagePath() . 'Configuration/SiteConfiguration/Overrides');
70  } catch (\InvalidArgumentException $e) {
71  // No such directory in this package
72  continue;
73  }
74  $hasDirectoryEntries = true;
75  }
76  if ($hasDirectoryEntries) {
77  foreach (‪$finder as $fileInfo) {
78  require $fileInfo->getPathname();
79  }
80  }
81  $result = ‪$GLOBALS['SiteConfiguration'];
82  unset(‪$GLOBALS['SiteConfiguration']);
83  $tcaMigration = GeneralUtility::makeInstance(TcaMigration::class);
84  $result = $tcaMigration->migrate($result);
85  $messages = $tcaMigration->getMessages();
86  if (!empty($messages)) {
87  $context = 'Automatic TCA migration done during bootstrap of Site TCA Configuration.'
88  . ' Please adapt TCA accordingly, these migrations will be removed.'
89  . ' Please adapt these areas:';
90  array_unshift($messages, $context);
91  trigger_error(implode(LF, $messages), E_USER_DEPRECATED);
92  }
93  return $result;
94  }
95 }
‪TYPO3\CMS\Backend\Configuration\SiteTcaConfiguration
Definition: SiteTcaConfiguration.php:34
‪TYPO3\CMS\Core\Migrations\TcaMigration
Definition: TcaMigration.php:31
‪$finder
‪if(PHP_SAPI !=='cli') $finder
Definition: header-comment.php:22
‪TYPO3\CMS\Backend\Configuration\SiteTcaConfiguration\getTca
‪getTca()
Definition: SiteTcaConfiguration.php:43
‪TYPO3\CMS\Backend\Configuration
Definition: BackendUserConfiguration.php:18
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:51