‪TYPO3CMS  10.4
TcaColumnsProcessPlaceholders.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
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 (strpos($fieldConfig['config']['placeholder'], '__row|') === 0) {
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 }
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaColumnsProcessPlaceholders\addData
‪array addData(array $result)
Definition: TcaColumnsProcessPlaceholders.php:34
‪TYPO3\CMS\Backend\Form\FormDataProvider
Definition: AbstractDatabaseRecordProvider.php:16
‪TYPO3\CMS\Backend\Form\FormDataProviderInterface
Definition: FormDataProviderInterface.php:23
‪TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode
‪static string[] trimExplode($delim, $string, $removeEmptyValues=false, $limit=0)
Definition: GeneralUtility.php:1059
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaColumnsProcessPlaceholders
Definition: TcaColumnsProcessPlaceholders.php:25