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