[TASK] FormEngine: Replace placeholder resolving with a data provider
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Form / FormDataGroup / TcaInputPlaceholderRecord.php
1 <?php
2 namespace TYPO3\CMS\Backend\Form\FormDataGroup;
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 use TYPO3\CMS\Backend\Form\FormDataGroupInterface;
18 use TYPO3\CMS\Backend\Form\FormDataProviderInterface;
19 use TYPO3\CMS\Core\Service\DependencyOrderingService;
20 use TYPO3\CMS\Core\Utility\GeneralUtility;
21
22 /**
23 * A data provider group for database records used for input placeholder values
24 */
25 class TcaInputPlaceholderRecord implements FormDataGroupInterface {
26
27 /**
28 * Compile form data
29 *
30 * @param array $result Initialized result array
31 * @return array Result filled with data
32 * @throws \UnexpectedValueException
33 */
34 public function compile(array $result) {
35 $dataProvider = $GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['formDataGroup']['tcaInputPlaceholderRecord'];
36 $orderingService = GeneralUtility::makeInstance(DependencyOrderingService::class);
37 $orderedDataProvider = $orderingService->orderByDependencies($dataProvider, 'before', 'depends');
38
39 foreach ($orderedDataProvider as $providerClassName => $_) {
40 /** @var FormDataProviderInterface $provider */
41 $provider = GeneralUtility::makeInstance($providerClassName);
42
43 if (!$provider instanceof FormDataProviderInterface) {
44 throw new \UnexpectedValueException(
45 'Data provider ' . $providerClassName . ' must implement FormDataProviderInterface',
46 1443986127
47 );
48 }
49
50 $result = $provider->addData($result);
51 }
52
53 return $result;
54 }
55
56 }