2 namespace TYPO3\CMS\Backend\Form\FormDataProvider;
39 if (!isset($result[
'processedTca'][
'types'])
40 || !is_array($result[
'processedTca'][
'types'])
41 || empty($result[
'processedTca'][
'types'])
43 throw new \UnexpectedValueException(
44 'At least one "types" array must be defined for table ' . $result[
'tableName'] .
', preferred "0"',
49 $recordTypeValue =
'0';
50 if (!empty($result[
'processedTca'][
'ctrl'][
'type'])) {
51 $tcaTypeField = $result[
'processedTca'][
'ctrl'][
'type'];
53 if (strpos($tcaTypeField,
':') ===
false) {
55 if (!array_key_exists($tcaTypeField, $result[
'databaseRow'])) {
56 throw new \UnexpectedValueException(
57 'TCA table ' . $result[
'tableName'] .
' ctrl[\'type\'] is set to ' . $tcaTypeField .
', but'
58 .
' this field does not exist in the database of this table',
68 list($pointerField, $foreignTableTypeField) = explode(
':', $tcaTypeField);
70 $relationType = $result[
'processedTca'][
'columns'][$pointerField][
'config'][
'type'];
71 if ($relationType !==
'select' && $relationType !==
'group') {
72 throw new \UnexpectedValueException(
73 'TCA foreign field pointer fields are only allowed to be used with group or select field types.'
74 .
' Handling field ' . $pointerField .
' with type configured as ' . $tcaTypeField,
81 if (!empty($foreignUid)) {
83 if ($relationType ===
'select') {
84 $foreignTable = $result[
'processedTca'][
'columns'][$pointerField][
'config'][
'foreign_table'];
86 $allowedTables = explode(
',', $result[
'processedTca'][
'columns'][$pointerField][
'config'][
'allowed']);
88 $foreignTable = $allowedTables[0];
90 if (empty($foreignTable)) {
91 throw new \UnexpectedValueException(
92 'No target table defined for type config field ' . $pointerField .
' of table ' . $result[
'tableName'],
99 list($foreignUid) = explode(
'|', $foreignUid);
100 $foreignUid = str_replace($foreignTable .
'_',
'', $foreignUid);
104 if ($foreignRow[$foreignTableTypeField]) {
109 $recordTypeValue = $foreignRow[$foreignTableTypeField];
116 if (empty($result[
'processedTca'][
'types'][$recordTypeValue])
117 && empty($result[
'processedTca'][
'types'][
'0'])
118 && empty($result[
'processedTca'][
'types'][
'1'])
120 throw new \UnexpectedValueException(
121 'Type value ' . $recordTypeValue .
' from database record not defined in TCA of table '
122 . $result[
'tableName'] .
' and neither 0 nor 1 are defined as fallback.',
128 if (empty($result[
'processedTca'][
'types'][$recordTypeValue])) {
129 $recordTypeValue = !empty($result[
'processedTca'][
'types'][
'0']) ?
'0' :
'1';
132 $result[
'recordTypeValue'] = (string)$recordTypeValue;
147 $value = $result[
'databaseRow'][$field];
150 !empty($result[
'processedTca'][
'ctrl'][
'languageField'])
151 && $result[
'databaseRow'][$result[
'processedTca'][
'ctrl'][
'languageField']] > 0
153 && !empty($result[
'processedTca'][
'columns'][$field][
'l10n_mode'])
156 $result[
'processedTca'][
'columns'][$field][
'l10n_mode'] ===
'exclude'
159 $result[
'processedTca'][
'columns'][$field][
'l10n_mode'] ===
'mergeIfNotBlank'
161 && $result[
'databaseRow'][$field] ===
''
165 $value = $result[
'defaultLanguageRow'][$field];