[BUGFIX] Fix foreign_table_where GROUP BY handling
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Form / FormDataProvider / TcaColumnsProcessPlaceholders.php
1 <?php
2 namespace TYPO3\CMS\Backend\Form\FormDataProvider;
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\FormDataProviderInterface;
18 use TYPO3\CMS\Core\Utility\GeneralUtility;
19
20 /**
21 * Mark columns that are used by input placeholders for further processing
22 */
23 class TcaColumnsProcessPlaceholders implements FormDataProviderInterface
24 {
25 /**
26 * Determine which fields are required to render the placeholders and
27 * add those to the list of columns that must be processed by the next
28 * data providers.
29 *
30 * @param array $result
31 * @return array
32 */
33 public function addData(array $result)
34 {
35 foreach ($result['processedTca']['columns'] as $fieldName => $fieldConfig) {
36 // Placeholders are only valid for input and text type fields
37 if (
38 ($fieldConfig['config']['type'] !== 'input' && $fieldConfig['config']['type'] !== 'text')
39 || !isset($fieldConfig['config']['placeholder'])
40 ) {
41 continue;
42 }
43
44 // Process __row|field type placeholders
45 if (strpos($fieldConfig['config']['placeholder'], '__row|') === 0) {
46 // split field names into array and remove the __row indicator
47 $fieldNameArray = array_slice(
48 GeneralUtility::trimExplode('|', $fieldConfig['config']['placeholder'], true),
49 1
50 );
51
52 // only the first field is required to be processed as it's the one referring to
53 // the current record. All other columns will be resolved in a later pass through
54 // the related records.
55 if (!empty($fieldNameArray[0])) {
56 $result['columnsToProcess'][] = $fieldNameArray[0];
57 }
58 }
59 }
60
61 return $result;
62 }
63 }