diff --git a/lib/classes/JsonApi/Schemas/Courseware/Block.php b/lib/classes/JsonApi/Schemas/Courseware/Block.php index 0bbe578a2deeba0e2c7c14125eba97c26d89e243..03eb56b8a4fbbdbf6ca1f622886ddfa96bffedca 100644 --- a/lib/classes/JsonApi/Schemas/Courseware/Block.php +++ b/lib/classes/JsonApi/Schemas/Courseware/Block.php @@ -67,14 +67,16 @@ class Block extends SchemaProvider self::RELATIONSHIP_DATA => $resource->container, ]; - $relationships[self::REL_OWNER] = [ + $relationships[self::REL_OWNER] = $resource->owner + ? [ self::RELATIONSHIP_LINKS => [ Link::RELATED => $this->createLinkToResource($resource->owner), ], self::RELATIONSHIP_DATA => $resource->owner, - ]; + ] + : [self::RELATIONSHIP_DATA => null]; - $relationships[self::REL_EDITOR] = $resource['editor_id'] + $relationships[self::REL_EDITOR] = $resource->editor ? [ self::RELATIONSHIP_LINKS => [ Link::RELATED => $this->createLinkToResource($resource->editor), @@ -84,7 +86,7 @@ class Block extends SchemaProvider : [self::RELATIONSHIP_DATA => null]; - $relationships[self::REL_EDITBLOCKER] = $resource['edit_blocker_id'] + $relationships[self::REL_EDITBLOCKER] = $resource->edit_blocker ? [ self::RELATIONSHIP_LINKS_SELF => true, self::RELATIONSHIP_LINKS => [ diff --git a/lib/classes/JsonApi/Schemas/Courseware/Container.php b/lib/classes/JsonApi/Schemas/Courseware/Container.php index 7842de2c7b3d8e8e277bced2190ee76dd23fc555..fd33c5c2df0e2faae88840d3c2b4e3d97645cc39 100644 --- a/lib/classes/JsonApi/Schemas/Courseware/Container.php +++ b/lib/classes/JsonApi/Schemas/Courseware/Container.php @@ -50,7 +50,7 @@ class Container extends SchemaProvider $relationships = []; $relationships = $this->addBlocksRelationship($relationships, $resource, $this->shouldInclude($context, self::REL_BLOCKS)); - $relationships[self::REL_OWNER] = $resource['owner_id'] + $relationships[self::REL_OWNER] = $resource->owner ? [ self::RELATIONSHIP_LINKS => [ Link::RELATED => $this->createLinkToResource($resource->owner), @@ -59,7 +59,7 @@ class Container extends SchemaProvider ] : [self::RELATIONSHIP_DATA => $resource->owner]; - $relationships[self::REL_EDITOR] = $resource['editor_id'] + $relationships[self::REL_EDITOR] = $resource->editor ? [ self::RELATIONSHIP_LINKS => [ Link::RELATED => $this->createLinkToResource($resource->editor), @@ -68,7 +68,7 @@ class Container extends SchemaProvider ] : [self::RELATIONSHIP_DATA => null]; - $relationships[self::REL_EDITBLOCKER] = $resource['edit_blocker_id'] + $relationships[self::REL_EDITBLOCKER] = $resource->edit_blocker ? [ self::RELATIONSHIP_LINKS_SELF => true, self::RELATIONSHIP_LINKS => [