Skip to content

Commit

Permalink
Also set publication->schema to match publication->metaData
Browse files Browse the repository at this point in the history
  • Loading branch information
WilcoLouwerse committed Aug 12, 2024
1 parent df9f3c4 commit ce4add4
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/Db/Publication.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,15 @@ public function hydrate(array $object): self
$this->setModified(new DateTime());


if(isset($object['published']) === false) {
if (isset($object['published']) === false) {
$object['published'] = null;
}

// Todo: MetaData is depricated, we should use Schema instead. But this needs front-end changes as well.
if (empty($object['schema']) === true) {
$object['schema'] = $object['metaData'] ?? $this->getMetaData();
}

foreach($object as $key => $value) {
if (in_array($key, $jsonFields) === true && $value === []) {
$value = null;
Expand All @@ -96,9 +101,6 @@ public function hydrate(array $object): self
}
}

// Todo: MetaData is depricated, we should use Schema instead. But this needs front-end changes as well.
$this->setSchema($this->getMetaData());

$this->setAttachmentCount('0');
if($this->attachments !== null) {
$this->setAttachmentCount(count($this->getAttachments()));
Expand Down Expand Up @@ -127,7 +129,7 @@ public function jsonSerialize(): array
'data' => $this->data,
'attachments' => $this->attachments,
'attachmentCount' => $this->attachmentCount,
'schema' => $this->schema,
'schema' => json_decode($this->schema, true),
'status' => $this->status,
'license' => $this->license,
'themes' => $this->themes,
Expand Down

0 comments on commit ce4add4

Please sign in to comment.