fix: [meta] template loading reworked

- no more crappy string numeric keys among others
cli-modification-summary
iglocska 2022-08-19 13:01:47 +02:00
parent b9e5b76766
commit 3e0d015f69
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
1 changed files with 5 additions and 3 deletions

View File

@ -381,7 +381,6 @@ class CRUDComponent extends Component
} else {
$entity->meta_fields = [];
}
$metaFieldsToDelete = [];
foreach ($input['MetaTemplates'] as $template_id => $template) {
foreach ($template['meta_template_fields'] as $meta_template_field_id => $meta_template_field) {
@ -622,7 +621,7 @@ class CRUDComponent extends Component
if (empty($data[$metaField->meta_template_id][$metaField->meta_template_field_id])) {
$data[$metaField->meta_template_id][$metaField->meta_template_field_id] = [];
}
$data[$metaField->meta_template_id][$metaField->meta_template_field_id][$metaField->id] = $metaField;
$data[$metaField->meta_template_id][$metaField->meta_template_field_id][] = $metaField;
}
return $data;
}
@ -643,6 +642,9 @@ class CRUDComponent extends Component
$metaTemplates[$metaTemplate->id]->meta_template_fields[$j]['metaFields'] = [];
}
}
if (!empty($metaTemplates[$metaTemplate->id]->meta_template_fields)) {
$metaTemplates[$metaTemplate->id]->meta_template_fields = array_values($metaTemplates[$metaTemplate->id]->meta_template_fields);
}
} else {
if (!empty($pruneEmptyDisabled) && !$metaTemplate->enabled) {
unset($metaTemplates[$i]);
@ -653,7 +655,7 @@ class CRUDComponent extends Component
$metaTemplates[$i]['hasNewerVersion'] = $newestTemplate;
}
}
$data['MetaTemplates'] = $metaTemplates;
$data['MetaTemplates'] = array_values($metaTemplates);
return $data;
}