Skip to content

Commit

Permalink
fix(admin/asset-field): asset field remove 'sha1' and '_hash' field (e…
Browse files Browse the repository at this point in the history
  • Loading branch information
Davidmattei authored Sep 19, 2024
1 parent 799f1c1 commit 3a8a094
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions EMS/core-bundle/src/Form/DataField/AssetFieldType.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public static function loadFromDb(array &$data): void
EmsFields::CONTENT_FILE_SIZE_FIELD_ => EmsFields::CONTENT_FILE_SIZE_FIELD,
EmsFields::CONTENT_MIME_TYPE_FIELD_ => EmsFields::CONTENT_MIME_TYPE_FIELD,
] as $newField => $oldField) {
if (!isset($data[$newField]) && isset($data[$oldField])) {
$data[$newField] = $data[$oldField];
}
if (!isset($data[$newField])) {
continue;
}
Expand All @@ -59,11 +62,13 @@ public static function loadFromDb(array &$data): void
foreach ($data as $id => $content) {
if (!\in_array($id, [EmsFields::CONTENT_FILE_HASH_FIELD_, EmsFields::CONTENT_FILE_NAME_FIELD_, EmsFields::CONTENT_FILE_SIZE_FIELD_, EmsFields::CONTENT_MIME_TYPE_FIELD_, EmsFields::CONTENT_FILE_HASH_FIELD, EmsFields::CONTENT_FILE_NAME_FIELD, EmsFields::CONTENT_FILE_SIZE_FIELD, EmsFields::CONTENT_MIME_TYPE_FIELD, EmsFields::CONTENT_IMAGE_RESIZED_HASH_FIELD, EmsFields::CONTENT_FILE_DATE, EmsFields::CONTENT_FILE_AUTHOR, EmsFields::CONTENT_FILE_LANGUAGE, EmsFields::CONTENT_FILE_CONTENT, EmsFields::CONTENT_FILE_TITLE], true)) {
unset($data[$id]);
} elseif (EmsFields::CONTENT_FILE_HASH_FIELD_ !== $id && empty($data[$id])) {
unset($data[EmsFields::CONTENT_FILE_HASH_FIELD_]);
unset($data[EmsFields::CONTENT_FILE_HASH_FIELD]);
}
}

if (empty($data[EmsFields::CONTENT_FILE_HASH_FIELD_])) {
unset($data[EmsFields::CONTENT_FILE_HASH_FIELD_]);
unset($data[EmsFields::CONTENT_FILE_HASH_FIELD]);
}
}

/**
Expand Down

0 comments on commit 3a8a094

Please sign in to comment.