TYPO3 CMS  TYPO3_8-7
TcaText.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
22 
28 {
35  public function addData(array $result)
36  {
37  foreach ($result['processedTca']['columns'] as $fieldName => $fieldConfig) {
38  if (empty($fieldConfig['config']['type']) || $fieldConfig['config']['type'] !== 'text') {
39  continue;
40  }
41 
42  if (isset($fieldConfig['config']['enableRichtext']) && (bool)$fieldConfig['config']['enableRichtext'] === true) {
43  $richtextConfigurationProvider = GeneralUtility::makeInstance(Richtext::class);
44  $richtextConfiguration = $richtextConfigurationProvider->getConfiguration(
45  $result['tableName'],
46  $fieldName,
47  $result['effectivePid'],
48  (string)$result['recordTypeValue'],
49  $fieldConfig['config']
50  );
51  // remember RTE preset name
52  $result['processedTca']['columns'][$fieldName]['config']['richtextConfigurationName'] = $fieldConfig['config']['richtextConfiguration'] ?? '';
53  // Add final resolved configuration to TCA array
54  $result['processedTca']['columns'][$fieldName]['config']['richtextConfiguration'] = $richtextConfiguration;
55 
56  // If eval=null is set for field, value might be null ... don't transform anything in this case.
57  if ($result['databaseRow'][$fieldName] !== null) {
58  // Process "from-db-to-rte" on current value
59  $parseHTML = GeneralUtility::makeInstance(RteHtmlParser::class);
60  $parseHTML->init($result['tableName'] . ':' . $fieldName, $result['effectivePid']);
61  $result['databaseRow'][$fieldName] = $parseHTML->RTE_transform(
62  $result['databaseRow'][$fieldName],
63  [],
64  'rte',
65  $richtextConfiguration
66  );
67  }
68  }
69  }
70 
71  return $result;
72  }
73 }
static makeInstance($className,... $constructorArguments)