Skip to content

Commit

Permalink
fix: api form submission, files correctly return array
Browse files Browse the repository at this point in the history
Because we want to use the property parameter correctly

for getting the id of the first file it should be ?property=[files][0][id]
before this fix, files is an object and the property needs to be [files][0].id
  • Loading branch information
Davidmattei committed Apr 9, 2024
1 parent fb96c71 commit c03ca92
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion EMS/submission-bundle/src/Entity/FormSubmission.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ public function toArray(): array
}

if ($this->files->count() > 0) {
$data['files'] = $this->files->toArray();
$files = $this->files->toArray();
$data['files'] = \array_map(static fn (FormSubmissionFile $f) => $f->toArray(), $files);
} else {
unset($data['files']);
}
Expand Down
8 changes: 8 additions & 0 deletions EMS/submission-bundle/src/Entity/FormSubmissionFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ public function __construct(/**
* @return array<string, mixed>
*/
public function jsonSerialize(): array
{
return $this->toArray();
}

/**
* @return array<string, mixed>
*/
public function toArray(): array
{
return [
'id' => $this->id->toString(),
Expand Down

0 comments on commit c03ca92

Please sign in to comment.