Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems using ResourceDocument::fromObject #76

Open
ArminSchulz opened this issue Mar 9, 2024 · 0 comments
Open

Problems using ResourceDocument::fromObject #76

ArminSchulz opened this issue Mar 9, 2024 · 0 comments

Comments

@ArminSchulz
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant