TYPO3  7.6
TcaColumnsProcessPlaceholders.php
Go to the documentation of this file.
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 
20 
25 {
34  public function addData(array $result)
35  {
36  foreach ($result['processedTca']['columns'] as $fieldName => $fieldConfig) {
37  // Placeholders are only valid for input and text type fields
38  if (
39  ($fieldConfig['config']['type'] !== 'input' && $fieldConfig['config']['type'] !== 'text')
40  || !isset($fieldConfig['config']['placeholder'])
41  ) {
42  continue;
43  }
44 
45  // Process __row|field type placeholders
46  if (StringUtility::beginsWith($fieldConfig['config']['placeholder'], '__row|')) {
47  // split field names into array and remove the __row indicator
48  $fieldNameArray = array_slice(
49  GeneralUtility::trimExplode('|', $fieldConfig['config']['placeholder'], true),
50  1
51  );
52 
53  // only the first field is required to be processed as it's the one referring to
54  // the current record. All other columns will be resolved in a later pass through
55  // the related records.
56  if (!empty($fieldNameArray[0])) {
57  $result['columnsToProcess'][] = $fieldNameArray[0];
58  }
59  }
60  }
61 
62  return $result;
63  }
64 }