fix link-parent not-storable

This commit is contained in:
Yuri Kuznetsov
2023-04-06 18:57:38 +03:00
parent 922a2e835c
commit 65bef1df65
4 changed files with 95 additions and 3 deletions
+24
View File
@@ -43,6 +43,30 @@ class AfterUpgrade
'length' => 24,
]);
$this->fixParent($metadata);
$metadata->save();
}
private function fixParent(Metadata $metadata): void
{
foreach ($metadata->get(['entityDefs']) as $scope => $defs) {
foreach ($metadata->get(['entityDefs', $scope, 'fields']) as $field => $fieldDefs) {
$custom = $metadata->getCustom('entityDefs', $scope);
if (!$custom) {
continue;
}
if (
($fieldDefs['type'] ?? null) === 'linkParent' &&
($fieldDefs['notStorable'] ?? false)
) {
if ($custom?->fields?->$field?->notStorable) {
$metadata->delete('entityDefs', $scope, "fields.{$field}.notStorable");
}
}
}
}
}
}