‪TYPO3CMS  ‪main
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 {
33  public function ‪addData(array $result)
34  {
35  foreach ($result['processedTca']['columns'] as $fieldName => $fieldConfig) {
36  // Placeholders are only valid for input-like and text-like fields.
37  if (!isset($fieldConfig['config']['placeholder'], $fieldConfig['config']['type'])
38  || (
39  $fieldConfig['config']['type'] !== 'input'
40  && $fieldConfig['config']['type'] !== 'text'
41  && $fieldConfig['config']['type'] !== 'number'
42  && $fieldConfig['config']['type'] !== 'email'
43  && $fieldConfig['config']['type'] !== 'link'
44  && $fieldConfig['config']['type'] !== 'password'
45  && $fieldConfig['config']['type'] !== 'datetime'
46  && $fieldConfig['config']['type'] !== 'color'
47  && $fieldConfig['config']['type'] !== 'json'
48  )
49  ) {
50  continue;
51  }
52 
53  // Process __row|field type placeholders
54  if (str_starts_with($fieldConfig['config']['placeholder'], '__row|')) {
55  // split field names into array and remove the __row indicator
56  $fieldNameArray = array_slice(
57  ‪GeneralUtility::trimExplode('|', $fieldConfig['config']['placeholder'], true),
58  1
59  );
60 
61  // only the first field is required to be processed as it's the one referring to
62  // the current record. All other columns will be resolved in a later pass through
63  // the related records.
64  if (!empty($fieldNameArray[0])) {
65  $result['columnsToProcess'][] = $fieldNameArray[0];
66  }
67  }
68  }
69 
70  return $result;
71  }
72 }
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaColumnsProcessPlaceholders\addData
‪array addData(array $result)
Definition: TcaColumnsProcessPlaceholders.php:33
‪TYPO3\CMS\Backend\Form\FormDataProvider
Definition: AbstractDatabaseRecordProvider.php:16
‪TYPO3\CMS\Backend\Form\FormDataProviderInterface
Definition: FormDataProviderInterface.php:23
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode
‪static list< string > trimExplode(string $delim, string $string, bool $removeEmptyValues=false, int $limit=0)
Definition: GeneralUtility.php:822
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaColumnsProcessPlaceholders
Definition: TcaColumnsProcessPlaceholders.php:25