[TASK] Re-work/simplify copyright header in PHP files - Part 2
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Classes / Configuration / TcaBuildingAspect.php
1 <?php
2 namespace TYPO3\CMS\Core\Configuration;
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
17 /**
18 * Assembles TCA overrides from packages to build the final TCA
19 */
20 class TcaBuildingAspect {
21
22 const TCA_OVERRIDES_PATH = 'Configuration/TCA/Overrides';
23
24 /**
25 * @var \TYPO3\CMS\Core\Package\PackageManager
26 * @inject
27 */
28 protected $packageManager;
29
30 /**
31 * @var \TYPO3\CMS\Core\Category\CategoryRegistry
32 * @inject
33 */
34 protected $categoryRegistry;
35
36 /**
37 * Scans active packages for TCA override code and executes it.
38 * Also applies category registry changes after that, so that
39 * registering calls to the registry can be (and should be) in TCA override files.
40 *
41 * @return array
42 */
43 public function applyTcaOverrides() {
44 $this->categoryRegistry->applyTcaForPreRegisteredTables();
45 foreach ($this->packageManager->getActivePackages() as $package) {
46 $tcaOverridesPathForPackage = $package->getPackagePath() . self::TCA_OVERRIDES_PATH;
47 if (is_dir($tcaOverridesPathForPackage)) {
48 $files = scandir($tcaOverridesPathForPackage);
49 foreach ($files as $file) {
50 if (
51 is_file($tcaOverridesPathForPackage . '/' . $file)
52 && ($file !== '.')
53 && ($file !== '..')
54 && (substr($file, -4, 4) === '.php')
55 ) {
56 require($tcaOverridesPathForPackage . '/' . $file);
57 }
58 }
59 }
60
61 }
62 return array($GLOBALS['TCA']);
63 }
64 }