Problems using ResourceDocument::fromObject
Hi, we use your implementation quite a lot in our projets, and until now, never had any problems (we appreciate your work tremendously). But now we have problems with answering a PUT request. using your code leads to a structure were the attributes of an ResourceObject more or less look like this
"data": { "type": "Event", "id": "196", "attributes":{ "type": "Event", "id": "196", "attributes": { "ClientID": 1 } } } which leads to an exception (type already used)
A solutions which works for us is simply: rewriting the function in ResourceDocument in this way:
public static function fromObject($attributes, $type=null, $id=null, array $options=[]) { $resourceDocument = new self(); $resourceDocument->setPrimaryResource($attributes->getResource(), $options); return $resourceDocument; } the document includes now all links, relationships, and so on, from the ResourceObject