36 if ($result[
'command'] !==
'new') {
39 if (!is_array($result[
'databaseRow'])) {
40 throw new \UnexpectedValueException(
41 'databaseRow of table ' . $result[
'tableName'] .
' is not an array',
53 $result = $this->
setPid($result);
66 $tableNameWithDot = $result[
'tableName'] .
'.';
68 if (isset($result[
'userTsConfig'][
'TCAdefaults.'][$tableNameWithDot])
69 && is_array($result[
'userTsConfig'][
'TCAdefaults.'][$tableNameWithDot])
71 foreach ($result[
'userTsConfig'][
'TCAdefaults.'][$tableNameWithDot] as $fieldName => $fieldValue) {
72 if (isset($result[
'processedTca'][
'columns'][$fieldName])) {
73 $result[
'databaseRow'][$fieldName] = $fieldValue;
88 $tableNameWithDot = $result[
'tableName'] .
'.';
89 if (isset($result[
'pageTsConfig'][
'TCAdefaults.'][$tableNameWithDot])
90 && is_array($result[
'pageTsConfig'][
'TCAdefaults.'][$tableNameWithDot])
92 foreach ($result[
'pageTsConfig'][
'TCAdefaults.'][$tableNameWithDot] as $fieldName => $fieldValue) {
93 if (isset($result[
'processedTca'][
'columns'][$fieldName])) {
94 $result[
'databaseRow'][$fieldName] = $fieldValue;
110 if (is_array($result[
'neighborRow'])
111 && !empty($result[
'processedTca'][
'ctrl'][
'useColumnsForDefaultValues'])
113 $defaultColumns = GeneralUtility::trimExplode(
',', $result[
'processedTca'][
'ctrl'][
'useColumnsForDefaultValues'],
true);
114 foreach ($defaultColumns as $fieldName) {
115 if (isset($result[
'processedTca'][
'columns'][$fieldName])
116 && isset($result[
'neighborRow'][$fieldName])
118 $result[
'databaseRow'][$fieldName] = $result[
'neighborRow'][$fieldName];
136 $tableName = $result[
'tableName'];
137 $defaultValues = $result[
'defaultValues'] ?? [];
138 if (isset($defaultValues[$tableName]) && is_array($defaultValues[$tableName])) {
139 foreach ($defaultValues[$tableName] as $fieldName => $fieldValue) {
140 if (isset($result[
'processedTca'][
'columns'][$fieldName])) {
141 $result[
'databaseRow'][$fieldName] = $fieldValue;
155 if (!empty($result[
'defaultValues'])) {
159 $defaultValues = GeneralUtility::_GP(
'defVals');
160 if (!empty($defaultValues)) {
162 'Default values for new database rows should be set from controller context. Applying default values'
163 .
' via GET/POST parameters is deprecated since 9.2 and will be removed in version 10',
166 $result[
'defaultValues'] = $defaultValues;
184 if ($result[
'inlineChildChildUid'] ===
null) {
187 if (!is_int($result[
'inlineChildChildUid'])) {
188 throw new \UnexpectedValueException(
189 'An inlineChildChildUid is given for table ' . $result[
'tableName'] .
', but is not an integer',
193 if (!isset($result[
'inlineParentConfig'][
'foreign_selector'])) {
194 throw new \UnexpectedValueException(
195 'An inlineChildChildUid is given for table ' . $result[
'tableName'] .
', but no foreign_selector in inlineParentConfig',
199 $selectorFieldName = $result[
'inlineParentConfig'][
'foreign_selector'];
200 if (!isset($result[
'processedTca'][
'columns'][$selectorFieldName][
'config'][
'type'])
202 $result[
'processedTca'][
'columns'][$selectorFieldName][
'config'][
'type'] !==
'select'
203 && $result[
'processedTca'][
'columns'][$selectorFieldName][
'config'][
'type'] !==
'group'
206 throw new \UnexpectedValueException(
207 $selectorFieldName .
' is target type of a foreign_selector field to table ' . $result[
'tableName'] .
' and must be either a select or group type field',
212 if ($result[
'inlineChildChildUid']) {
213 $result[
'databaseRow'][$selectorFieldName] = $result[
'inlineChildChildUid'];
232 if (!isset($result[
'inlineParentConfig'][
'inline'][
'parentSysLanguageUid'])
233 || empty($result[
'processedTca'][
'ctrl'][
'languageField'])
234 || empty($result[
'processedTca'][
'ctrl'][
'transOrigPointerField'])
240 throw new \UnexpectedValueException(
241 'A sys_language_uid is set from inline parent config but the value is no integer',
245 $parentSysLanguageUid = (int)$result[
'inlineParentConfig'][
'inline'][
'parentSysLanguageUid'];
246 $languageFieldName = $result[
'processedTca'][
'ctrl'][
'languageField'];
247 $result[
'databaseRow'][$languageFieldName] = $parentSysLanguageUid;
260 $isInlineChild = $result[
'isInlineChild'] ??
false;
261 $parentField = $result[
'inlineParentConfig'][
'foreign_field'] ??
false;
263 if ($isInlineChild && $parentField && !empty($result[
'inlineParentUid'])) {
264 $result[
'databaseRow'][$parentField] = $result[
'inlineParentUid'];
282 $result[
'databaseRow'][
'pid'] = $result[
'vanillaUid'];
287 $tableNameWithDot = $result[
'tableName'] .
'.';
288 if ($result[
'isInlineChild'] && isset($result[
'pageTsConfig'][
'TCAdefaults.'][$tableNameWithDot][
'pid'])) {
290 throw new \UnexpectedValueException(
291 'page TSConfig setting TCAdefaults.' . $tableNameWithDot .
'pid must be a number, but given string '
292 . $result[
'pageTsConfig'][
'TCAdefaults.'][$tableNameWithDot][
'pid'] .
' can not be interpreted as integer',
296 $result[
'databaseRow'][
'pid'] = (int)$result[
'pageTsConfig'][
'TCAdefaults.'][$tableNameWithDot][
'pid'];