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