‪TYPO3CMS  ‪main
TcaFlexProcess.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 
23 
30 {
41  public function ‪addData(array $result)
42  {
43  foreach ($result['processedTca']['columns'] as $fieldName => $fieldConfig) {
44  if (empty($fieldConfig['config']['type']) || $fieldConfig['config']['type'] !== 'flex') {
45  continue;
46  }
47  if (!isset($result['processedTca']['columns'][$fieldName]['config']['dataStructureIdentifier'])) {
48  throw new \RuntimeException(
49  'Data structure identifier must be set, typically by executing TcaFlexPrepare data provider before',
50  1480765571
51  );
52  }
53  $this->‪scanForInvalidSectionContainerTca($result, $fieldName);
54  $dataStructureIdentifier = $result['processedTca']['columns'][$fieldName]['config']['dataStructureIdentifier'];
55  $simpleDataStructureIdentifier = $this->‪getSimplifiedDataStructureIdentifier($dataStructureIdentifier);
56  $pageTsConfigOfFlex = $this->‪getPageTsOfFlex($result, $fieldName, $simpleDataStructureIdentifier);
57  $result = $this->‪modifyOuterDataStructure($result, $fieldName, $pageTsConfigOfFlex);
58  $result = $this->‪removeExcludeFieldsFromDataStructure($result, $fieldName, $simpleDataStructureIdentifier);
59  $result = $this->‪removeDisabledFieldsFromDataStructure($result, $fieldName, $pageTsConfigOfFlex);
60  // A "normal" call opening a record: Process data structure and field values
61  // This is called for "new" container ajax request too, since display conditions from section container
62  // elements can access record values of other flex form sheets and we need their values then.
63  $result = $this->‪modifyDataStructureAndDataValuesByFlexFormSegmentGroup($result, $fieldName, $pageTsConfigOfFlex);
64  if (!empty($result['flexSectionContainerPreparation'])) {
65  // Create data and default values for a new section container, set by FormFlexAjaxController
66  $result = $this->‪prepareNewSectionContainer($result, $fieldName);
67  }
68  }
69 
70  return $result;
71  }
72 
81  protected function ‪scanForInvalidSectionContainerTca(array $result, string $fieldName)
82  {
83  $dataStructure = $result['processedTca']['columns'][$fieldName]['config']['ds'];
84  if (!isset($dataStructure['sheets']) || !is_array($dataStructure['sheets'])) {
85  return;
86  }
87  foreach ($dataStructure['sheets'] as $dataStructureSheetName => $dataStructureSheetDefinition) {
88  if (!isset($dataStructureSheetDefinition['ROOT']['el']) || !is_array($dataStructureSheetDefinition['ROOT']['el'])) {
89  continue;
90  }
91  $dataStructureFields = $dataStructureSheetDefinition['ROOT']['el'];
92  foreach ($dataStructureFields as $dataStructureFieldName => $dataStructureFieldDefinition) {
93  if (isset($dataStructureFieldDefinition['type']) && $dataStructureFieldDefinition['type'] === 'array'
94  && isset($dataStructureFieldDefinition['section']) && (string)$dataStructureFieldDefinition['section'] === '1'
95  ) {
96  if (isset($dataStructureFieldDefinition['el']) && is_array($dataStructureFieldDefinition['el'])) {
97  foreach ($dataStructureFieldDefinition['el'] as $containerName => $containerConfiguration) {
98  if (isset($containerConfiguration['el']) && is_array($containerConfiguration['el'])) {
99  foreach ($containerConfiguration['el'] as $singleFieldName => $singleFieldConfiguration) {
100  // Nesting types that use DB relations in container sections is not supported.
101  if (isset($singleFieldConfiguration['config']['type'])) {
102  if (
103  // inline, file, group and category are always DB relations
104  in_array($singleFieldConfiguration['config']['type'], ['inline', 'file', 'folder', 'group', 'category'], true)
105  // MM is not allowed (usually type=select, otherwise the upper check should kick in)
106  || isset($singleFieldConfiguration['config']['MM'])
107  // foreign_table is not allowed (usually type=select, otherwise the upper check should kick in)
108  || isset($singleFieldConfiguration['config']['foreign_table'])
109  ) {
110  throw new \UnexpectedValueException(
111  'Invalid flex form data structure on field name "' . $fieldName . '" with element "' . $singleFieldName . '"'
112  . ' in section container "' . $containerName . '": Nesting elements that have database relations in flex form'
113  . ' sections is not allowed.',
114  1458745468
115  );
116  }
117  }
118  // Nesting sections is not supported. Throw an exception if configured.
119  if (is_array($singleFieldConfiguration)
120  && isset($singleFieldConfiguration['type']) && $singleFieldConfiguration['type'] === 'array'
121  && isset($singleFieldConfiguration['section']) && (string)$singleFieldConfiguration['section'] === '1'
122  ) {
123  throw new \UnexpectedValueException(
124  'Invalid flex form data structure on field name "' . $fieldName . '" with element "' . $singleFieldName . '"'
125  . ' in section container "' . $containerName . '": Nesting sections in container elements'
126  . ' sections is not allowed.',
127  1458745712
128  );
129  }
130  }
131  }
132  }
133  }
134  } elseif (isset($dataStructureFieldDefinition['type']) xor isset($dataStructureFieldDefinition['section'])) {
135  // type without section is not ok
136  throw new \UnexpectedValueException(
137  'Broken data structure on field name ' . $fieldName . '. section without type or vice versa is not allowed',
138  1440685208
139  );
140  }
141  }
142  }
143  }
144 
179  protected function ‪getSimplifiedDataStructureIdentifier(string $dataStructureIdentifier): string
180  {
181  $identifierArray = json_decode($dataStructureIdentifier, true);
182  $simpleDataStructureIdentifier = 'default';
183  if (isset($identifierArray['type']) && $identifierArray['type'] === 'tca' && isset($identifierArray['dataStructureKey'])) {
184  $explodedKey = explode(',', $identifierArray['dataStructureKey']);
185  if (!empty($explodedKey[1]) && $explodedKey[1] !== 'list' && $explodedKey[1] !== '*') {
186  $simpleDataStructureIdentifier = $explodedKey[1];
187  } elseif (!empty($explodedKey[0]) && $explodedKey[0] !== 'list' && $explodedKey[0] !== '*') {
188  $simpleDataStructureIdentifier = $explodedKey[0];
189  }
190  }
191  return $simpleDataStructureIdentifier;
192  }
193 
202  protected function ‪getPageTsOfFlex(array $result, $fieldName, $flexIdentifier)
203  {
204  $table = $result['tableName'];
205  $pageTs = [];
206  if (!empty($result['pageTsConfig']['TCEFORM.'][$table . '.'][$fieldName . '.'][$flexIdentifier . '.'])
207  && is_array($result['pageTsConfig']['TCEFORM.'][$table . '.'][$fieldName . '.'][$flexIdentifier . '.'])) {
208  $pageTs = $result['pageTsConfig']['TCEFORM.'][$table . '.'][$fieldName . '.'][$flexIdentifier . '.'];
209  }
210  return $pageTs;
211  }
212 
222  protected function ‪modifyOuterDataStructure(array $result, $fieldName, $pageTsConfig)
223  {
224  $modifiedDataStructure = $result['processedTca']['columns'][$fieldName]['config']['ds'];
225 
226  if (isset($modifiedDataStructure['sheets']) && is_array($modifiedDataStructure['sheets'])) {
227  // Handling multiple sheets
228  foreach ($modifiedDataStructure['sheets'] as $sheetName => $sheetStructure) {
229  if (isset($pageTsConfig[$sheetName . '.']) && is_array($pageTsConfig[$sheetName . '.'])) {
230  $pageTsOfSheet = $pageTsConfig[$sheetName . '.'];
231 
232  // Remove whole sheet if disabled
233  if (!empty($pageTsOfSheet['disabled'])) {
234  unset($modifiedDataStructure['sheets'][$sheetName]);
235  continue;
236  }
237 
238  // sheetTitle, sheetDescription, sheetShortDescr
239  $modifiedDataStructure['sheets'][$sheetName] = $this->‪modifySingleSheetInformation($sheetStructure, $pageTsOfSheet);
240  }
241  }
242  }
243 
244  $result['processedTca']['columns'][$fieldName]['config']['ds'] = $modifiedDataStructure;
245 
246  return $result;
247  }
248 
257  protected function ‪removeExcludeFieldsFromDataStructure(array $result, $fieldName, $flexIdentifier)
258  {
259  $dataStructure = $result['processedTca']['columns'][$fieldName]['config']['ds'];
260  $backendUser = $this->‪getBackendUser();
261  if ($backendUser->isAdmin() || !isset($dataStructure['sheets']) || !is_array($dataStructure['sheets'])) {
262  return $result;
263  }
264 
265  $userNonExcludeFields = ‪GeneralUtility::trimExplode(',', $backendUser->groupData['non_exclude_fields']);
266  $excludeFieldsPrefix = $result['tableName'] . ':' . $fieldName . ';' . $flexIdentifier . ';';
267  $nonExcludeFields = [];
268  foreach ($userNonExcludeFields as $userNonExcludeField) {
269  if (str_contains($userNonExcludeField, $excludeFieldsPrefix)) {
270  $exploded = explode(';', $userNonExcludeField);
271  $sheetName = $exploded[2];
272  $allowedFlexFieldName = $exploded[3];
273  $nonExcludeFields[$sheetName][$allowedFlexFieldName] = true;
274  }
275  }
276  foreach ($dataStructure['sheets'] as $sheetName => $sheetDefinition) {
277  if (!isset($sheetDefinition['ROOT']['el']) || !is_array($sheetDefinition['ROOT']['el'])) {
278  continue;
279  }
280  foreach ($sheetDefinition['ROOT']['el'] as $flexFieldName => $fieldDefinition) {
281  if (!empty($fieldDefinition['exclude']) && !isset($nonExcludeFields[$sheetName][$flexFieldName])) {
282  unset($result['processedTca']['columns'][$fieldName]['config']['ds']['sheets'][$sheetName]['ROOT']['el'][$flexFieldName]);
283  }
284  }
285  }
286 
287  return $result;
288  }
289 
298  protected function ‪removeDisabledFieldsFromDataStructure(array $result, $fieldName, $pageTsConfig)
299  {
300  $dataStructure = $result['processedTca']['columns'][$fieldName]['config']['ds'];
301  if (!isset($dataStructure['sheets']) || !is_array($dataStructure['sheets'])) {
302  return $result;
303  }
304  foreach ($dataStructure['sheets'] as $sheetName => $sheetDefinition) {
305  if (!isset($sheetDefinition['ROOT']['el']) || !is_array($sheetDefinition['ROOT']['el'])
306  || !isset($pageTsConfig[$sheetName . '.'])) {
307  continue;
308  }
309  foreach ($sheetDefinition['ROOT']['el'] as $flexFieldName => $fieldDefinition) {
310  if (!empty($pageTsConfig[$sheetName . '.'][$flexFieldName . '.']['disabled'])) {
311  unset($result['processedTca']['columns'][$fieldName]['config']['ds']['sheets'][$sheetName]['ROOT']['el'][$flexFieldName]);
312  }
313  }
314  }
315  return $result;
316  }
317 
332  protected function ‪modifyDataStructureAndDataValuesByFlexFormSegmentGroup(array $result, $fieldName, $pageTsConfig)
333  {
334  $dataStructure = $result['processedTca']['columns'][$fieldName]['config']['ds'];
335  $dataValues = $result['databaseRow'][$fieldName];
336  $tableName = $result['tableName'];
337 
338  if (!isset($dataStructure['sheets']) || !is_array($dataStructure['sheets'])) {
339  return $result;
340  }
341 
342  $formDataGroup = GeneralUtility::makeInstance(FlexFormSegment::class);
343  $formDataCompiler = GeneralUtility::makeInstance(FormDataCompiler::class);
344 
345  foreach ($dataStructure['sheets'] as $dataStructureSheetName => $dataStructureSheetDefinition) {
346  if (!isset($dataStructureSheetDefinition['ROOT']['el']) || !is_array($dataStructureSheetDefinition['ROOT']['el'])) {
347  continue;
348  }
349  $dataStructureFields = $dataStructureSheetDefinition['ROOT']['el'];
350 
351  // Prepare pageTsConfig of this sheet
352  $pageTsConfig['TCEFORM.'][$tableName . '.'] = [];
353  if (isset($pageTsConfig[$dataStructureSheetName . '.']) && is_array($pageTsConfig[$dataStructureSheetName . '.'])) {
354  $pageTsConfig['TCEFORM.'][$tableName . '.'] = $pageTsConfig[$dataStructureSheetName . '.'];
355  }
356 
357  // List of "new" tca fields that have no value within the flexform, yet. Those will be compiled in one go later.
358  $tcaNewColumns = [];
359  // List of "edit" tca fields that have a value in flexform, already. Those will be compiled in one go later.
360  $tcaEditColumns = [];
361  // Contains the data values for the "edit" tca fields.
362  $tcaValueArray = [
363  'uid' => $result['databaseRow']['uid'],
364  ];
365  foreach ($dataStructureFields as $dataStructureFieldName => $dataStructureFieldDefinition) {
366  if (isset($dataStructureFieldDefinition['type']) && $dataStructureFieldDefinition['type'] === 'array'
367  && isset($dataStructureFieldDefinition['section']) && (string)$dataStructureFieldDefinition['section'] === '1'
368  ) {
369  // Existing section containers. Prepare data values and create a unique data structure per container.
370  // This is important for instance for display conditions later enabling them to change ds per container instance.
371  // In the end, the data values in
372  // ['databaseRow']['aFieldName']['data']['aSheet']['lDEF']['aSectionField']['el']['aContainer']
373  // are prepared, and additionally, the processedTca data structure is changed and has a specific container
374  // name per container instance in
375  // ['processedTca']['columns']['aFieldName']['config']['ds']['sheets']['aSheet']['ROOT']['el']['aSectionField']['children']['aContainer']
376  if (isset($dataValues['data'][$dataStructureSheetName]['lDEF'][$dataStructureFieldName]['el'])
377  && is_array($dataValues['data'][$dataStructureSheetName]['lDEF'][$dataStructureFieldName]['el'])
378  ) {
379  $containerValueArray = $dataValues['data'][$dataStructureSheetName]['lDEF'][$dataStructureFieldName]['el'];
380  $containerDataStructuresPerContainer = [];
381  foreach ($containerValueArray as $aContainerIdentifier => $aContainerArray) {
382  if (is_array($aContainerArray)) {
383  foreach ($aContainerArray as $aContainerName => $aContainerElementArray) {
384  if (!isset($dataStructureFields[$dataStructureFieldName]['el'][$aContainerName])) {
385  // Container not defined in ds
386  continue;
387  }
388  $vanillaContainerDataStructure = $dataStructureFields[$dataStructureFieldName]['el'][$aContainerName];
389 
390  $newColumns = [];
391  $editColumns = [];
392  $valueArray = [
393  'uid' => $result['databaseRow']['uid'],
394  ];
395  foreach ($vanillaContainerDataStructure['el'] as $singleFieldName => $singleFieldConfiguration) {
396  // $singleFieldValueArray = ['data']['sSections']['lDEF']['section_1']['el']['1']['container_1']['el']['element_1']
397  $singleFieldValueArray = [];
398  if (isset($aContainerElementArray['el'][$singleFieldName])
399  && is_array($aContainerElementArray['el'][$singleFieldName])
400  ) {
401  $singleFieldValueArray = $aContainerElementArray['el'][$singleFieldName];
402  }
403 
404  if (array_key_exists('vDEF', $singleFieldValueArray)) {
405  $valueArray[$singleFieldName] = $singleFieldValueArray['vDEF'];
406  } else {
407  $newColumns[$singleFieldName] = $singleFieldConfiguration;
408  }
409  $editColumns[$singleFieldName] = $singleFieldConfiguration;
410  }
411 
412  $inputToFlexFormSegment = [
413  'request' => $result['request'],
414  'tableName' => $result['tableName'],
415  'command' => '',
416  // It is currently not possible to have pageTsConfig for section container
417  'pageTsConfig' => [],
418  'databaseRow' => $valueArray,
419  'processedTca' => [
420  'ctrl' => [],
421  'columns' => [],
422  ],
423  'selectTreeCompileItems' => $result['selectTreeCompileItems'],
424  'flexParentDatabaseRow' => $result['databaseRow'],
425  'effectivePid' => $result['effectivePid'],
426  ];
427 
428  if (!empty($newColumns)) {
429  // This is scenario "field has been added to data structure, but field value does not exist in value array yet"
430  // We want that stuff like TCA "default" values are then applied to those fields. What we do here is
431  // calling the data compiler with those "new" fields to fetch their values and set them in value array.
432  // Those fields are then compiled a second time in the "edit" phase to prepare their final TCA.
433  // This two-phase compiling is needed to ensure that for instance display conditions work with
434  // fields that may just have been added to the data structure but are not yet initialized as data value.
435  $inputToFlexFormSegment['command'] = 'new';
436  $inputToFlexFormSegment['processedTca']['columns'] = $newColumns;
437  $flexSegmentResult = $formDataCompiler->compile($inputToFlexFormSegment, $formDataGroup);
438  foreach ($newColumns as $singleFieldName => $_) {
439  // Set data value result to feed it to "edit" next
440  $valueArray[$singleFieldName] = $flexSegmentResult['databaseRow'][$singleFieldName];
441  }
442  }
443 
444  if (!empty($editColumns)) {
445  $inputToFlexFormSegment['command'] = 'edit';
446  $inputToFlexFormSegment['processedTca']['columns'] = $editColumns;
447  $flexSegmentResult = $formDataCompiler->compile($inputToFlexFormSegment, $formDataGroup);
448  foreach ($editColumns as $singleFieldName => $_) {
449  $result['databaseRow'][$fieldName]
450  ['data'][$dataStructureSheetName]['lDEF'][$dataStructureFieldName]
451  ['el'][$aContainerIdentifier][$aContainerName]['el'][$singleFieldName]['vDEF']
452  = $flexSegmentResult['databaseRow'][$singleFieldName];
453  $containerDataStructuresPerContainer[$aContainerIdentifier] = $vanillaContainerDataStructure;
454  $containerDataStructuresPerContainer[$aContainerIdentifier]['el'] = $flexSegmentResult['processedTca']['columns'];
455  }
456  }
457  }
458  }
459  } // End of existing data value handling
460  // Set 'data structures per container' next to 'el' that contains vanilla data structures
461  $result['processedTca']['columns'][$fieldName]['config']['ds']
462  ['sheets'][$dataStructureSheetName]['ROOT']['el']
463  [$dataStructureFieldName]['children'] = $containerDataStructuresPerContainer;
464  } else {
465  // Force the section data array to be an empty array if there are no existing containers
466  $result['databaseRow'][$fieldName]
467  ['data'][$dataStructureSheetName]['lDEF'][$dataStructureFieldName]['el'] = [];
468  // Force data structure array to be empty if there are no existing containers
469  $result['processedTca']['columns'][$fieldName]['config']['ds']
470  ['sheets'][$dataStructureSheetName]['ROOT']['el']
471  [$dataStructureFieldName]['children'] = [];
472  }
473  } else {
474  // A "normal" TCA flex form element, no section
475  if (isset($dataValues['data'][$dataStructureSheetName]['lDEF'][$dataStructureFieldName])
476  && array_key_exists('vDEF', $dataValues['data'][$dataStructureSheetName]['lDEF'][$dataStructureFieldName])
477  ) {
478  $tcaEditColumns[$dataStructureFieldName] = $dataStructureFieldDefinition;
479  $tcaValueArray[$dataStructureFieldName] = $dataValues['data'][$dataStructureSheetName]['lDEF'][$dataStructureFieldName]['vDEF'];
480  } else {
481  $tcaNewColumns[$dataStructureFieldName] = $dataStructureFieldDefinition;
482  }
483  } // End of single element handling
484  }
485 
486  // process the tca columns for the current sheet
487  $inputToFlexFormSegment = [
488  'request' => $result['request'],
489  'tableName' => $result['tableName'],
490  'command' => '',
491  'pageTsConfig' => $pageTsConfig,
492  'databaseRow' => $tcaValueArray,
493  'processedTca' => [
494  'ctrl' => [],
495  'columns' => [],
496  ],
497  'flexParentDatabaseRow' => $result['databaseRow'],
498  // Whether to compile TCA tree items - inherit from parent
499  'selectTreeCompileItems' => $result['selectTreeCompileItems'],
500  'effectivePid' => $result['effectivePid'],
501  ];
502 
503  if (!empty($tcaNewColumns)) {
504  // @todo: this has the same problem in scenario "a field was added later" as flex section container
505  $inputToFlexFormSegment['command'] = 'new';
506  $inputToFlexFormSegment['processedTca']['columns'] = $tcaNewColumns;
507  $flexSegmentResult = $formDataCompiler->compile($inputToFlexFormSegment, $formDataGroup);
508 
509  foreach ($tcaNewColumns as $dataStructureFieldName => $_) {
510  // Set data value result
511  if (array_key_exists($dataStructureFieldName, $flexSegmentResult['databaseRow'])) {
512  $result['databaseRow'][$fieldName]
513  ['data'][$dataStructureSheetName]['lDEF'][$dataStructureFieldName]['vDEF']
514  = $flexSegmentResult['databaseRow'][$dataStructureFieldName];
515  }
516  // Set TCA structure result
517  $result['processedTca']['columns'][$fieldName]['config']['ds']
518  ['sheets'][$dataStructureSheetName]['ROOT']['el'][$dataStructureFieldName]
519  = $flexSegmentResult['processedTca']['columns'][$dataStructureFieldName];
520  }
521  }
522 
523  if (!empty($tcaEditColumns)) {
524  $inputToFlexFormSegment['command'] = 'edit';
525  $inputToFlexFormSegment['processedTca']['columns'] = $tcaEditColumns;
526  $flexSegmentResult = $formDataCompiler->compile($inputToFlexFormSegment, $formDataGroup);
527 
528  foreach ($tcaEditColumns as $dataStructureFieldName => $_) {
529  // Set data value result
530  if (array_key_exists($dataStructureFieldName, $flexSegmentResult['databaseRow'])) {
531  $result['databaseRow'][$fieldName]
532  ['data'][$dataStructureSheetName]['lDEF'][$dataStructureFieldName]['vDEF']
533  = $flexSegmentResult['databaseRow'][$dataStructureFieldName];
534  }
535  // Set TCA structure result
536  $result['processedTca']['columns'][$fieldName]['config']['ds']
537  ['sheets'][$dataStructureSheetName]['ROOT']['el'][$dataStructureFieldName]
538  = $flexSegmentResult['processedTca']['columns'][$dataStructureFieldName];
539  }
540  }
541  }
542 
543  return $result;
544  }
545 
553  protected function ‪prepareNewSectionContainer(array $result, string $fieldName): array
554  {
555  $flexSectionContainerPreparation = $result['flexSectionContainerPreparation'];
556  $flexFormSheetName = $flexSectionContainerPreparation['flexFormSheetName'];
557  $flexFormFieldName = $flexSectionContainerPreparation['flexFormFieldName'];
558  $flexFormContainerName = $flexSectionContainerPreparation['flexFormContainerName'];
559  $flexFormContainerIdentifier = $flexSectionContainerPreparation['flexFormContainerIdentifier'];
560 
561  $containerConfiguration = $result['processedTca']['columns'][$fieldName]['config']['ds']
562  ['sheets'][$flexFormSheetName]['ROOT']['el'][$flexFormFieldName]['el'][$flexFormContainerName] ?? [];
563 
564  if (isset($containerConfiguration['el']) && is_array($containerConfiguration['el'])) {
565  $formDataCompiler = GeneralUtility::makeInstance(FormDataCompiler::class);
566  $inputToFlexFormSegment = [
567  'request' => $result['request'],
568  'tableName' => $result['tableName'],
569  'command' => 'new',
570  // It is currently not possible to have pageTsConfig for section container
571  'pageTsConfig' => [],
572  'databaseRow' => [
573  'uid' => $result['databaseRow']['uid'],
574  ],
575  'processedTca' => [
576  'ctrl' => [],
577  'columns' => $containerConfiguration['el'],
578  ],
579  'selectTreeCompileItems' => $result['selectTreeCompileItems'],
580  'flexParentDatabaseRow' => $result['databaseRow'],
581  'effectivePid' => $result['effectivePid'],
582  ];
583  $flexSegmentResult = $formDataCompiler->compile($inputToFlexFormSegment, GeneralUtility::makeInstance(FlexFormSegment::class));
584 
585  foreach ($containerConfiguration['el'] as $singleFieldName => $singleFieldConfiguration) {
586  // Set 'data structures for this new container' to 'children'
587  $result['processedTca']['columns'][$fieldName]['config']['ds']
588  ['sheets'][$flexFormSheetName]['ROOT']['el']
589  [$flexFormFieldName]['children'][$flexFormContainerIdentifier]
590  = $containerConfiguration;
591  $result['processedTca']['columns'][$fieldName]['config']['ds']
592  ['sheets'][$flexFormSheetName]['ROOT']['el']
593  [$flexFormFieldName]['children'][$flexFormContainerIdentifier]['el']
594  = $flexSegmentResult['processedTca']['columns'];
595  // Set calculated value - this especially contains "default values from TCA"
596  $result['databaseRow'][$fieldName]['data'][$flexFormSheetName]['lDEF']
597  [$flexFormFieldName]['el']
598  [$flexFormContainerIdentifier][$flexFormContainerName]['el'][$singleFieldName]['vDEF']
599  = $flexSegmentResult['databaseRow'][$singleFieldName];
600  }
601  }
602 
603  return $result;
604  }
605 
614  protected function ‪modifySingleSheetInformation(array $dataStructure, array $pageTsOfSheet)
615  {
616  // Return if no elements defined
617  if (!isset($dataStructure['ROOT']['el']) || !is_array($dataStructure['ROOT']['el'])) {
618  return $dataStructure;
619  }
620  // Rename sheet (tab)
621  if (!empty($pageTsOfSheet['sheetTitle'])) {
622  $dataStructure['ROOT']['sheetTitle'] = $pageTsOfSheet['sheetTitle'];
623  }
624  // Set sheet description (tab)
625  if (!empty($pageTsOfSheet['sheetDescription'])) {
626  $dataStructure['ROOT']['sheetDescription'] = $pageTsOfSheet['sheetDescription'];
627  }
628  // Set sheet short description (tab)
629  if (!empty($pageTsOfSheet['sheetShortDescr'])) {
630  $dataStructure['ROOT']['sheetShortDescr'] = $pageTsOfSheet['sheetShortDescr'];
631  }
632 
633  return $dataStructure;
634  }
635 
637  {
638  return ‪$GLOBALS['BE_USER'];
639  }
640 }
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaFlexProcess\removeDisabledFieldsFromDataStructure
‪array removeDisabledFieldsFromDataStructure(array $result, $fieldName, $pageTsConfig)
Definition: TcaFlexProcess.php:298
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaFlexProcess
Definition: TcaFlexProcess.php:30
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaFlexProcess\modifyDataStructureAndDataValuesByFlexFormSegmentGroup
‪array modifyDataStructureAndDataValuesByFlexFormSegmentGroup(array $result, $fieldName, $pageTsConfig)
Definition: TcaFlexProcess.php:332
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaFlexProcess\modifySingleSheetInformation
‪array modifySingleSheetInformation(array $dataStructure, array $pageTsOfSheet)
Definition: TcaFlexProcess.php:614
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaFlexProcess\getPageTsOfFlex
‪array getPageTsOfFlex(array $result, $fieldName, $flexIdentifier)
Definition: TcaFlexProcess.php:202
‪TYPO3\CMS\Backend\Form\FormDataGroup\FlexFormSegment
Definition: FlexFormSegment.php:25
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaFlexProcess\modifyOuterDataStructure
‪array modifyOuterDataStructure(array $result, $fieldName, $pageTsConfig)
Definition: TcaFlexProcess.php:222
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaFlexProcess\getBackendUser
‪getBackendUser()
Definition: TcaFlexProcess.php:636
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪TYPO3\CMS\Backend\Form\FormDataProvider
Definition: AbstractDatabaseRecordProvider.php:16
‪TYPO3\CMS\Backend\Form\FormDataProviderInterface
Definition: FormDataProviderInterface.php:23
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaFlexProcess\removeExcludeFieldsFromDataStructure
‪array removeExcludeFieldsFromDataStructure(array $result, $fieldName, $flexIdentifier)
Definition: TcaFlexProcess.php:257
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaFlexProcess\addData
‪array addData(array $result)
Definition: TcaFlexProcess.php:41
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaFlexProcess\scanForInvalidSectionContainerTca
‪scanForInvalidSectionContainerTca(array $result, string $fieldName)
Definition: TcaFlexProcess.php:81
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaFlexProcess\getSimplifiedDataStructureIdentifier
‪getSimplifiedDataStructureIdentifier(string $dataStructureIdentifier)
Definition: TcaFlexProcess.php:179
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Backend\Form\FormDataCompiler
Definition: FormDataCompiler.php:26
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaFlexProcess\prepareNewSectionContainer
‪array prepareNewSectionContainer(array $result, string $fieldName)
Definition: TcaFlexProcess.php:553
‪TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode
‪static list< string > trimExplode(string $delim, string $string, bool $removeEmptyValues=false, int $limit=0)
Definition: GeneralUtility.php:822