arangodb / arangodb-php

PHP ODM for ArangoDB
https://www.arangodb.com
Apache License 2.0
182 stars 46 forks source link

Arango document should implements JsonSerializable #244

Closed a-shafaat closed 6 years ago

a-shafaat commented 6 years ago

It's a minor change, but it's completely necessary. as an example consider a RestfulAPI written in PHP, think you did a byExample search for some documents, so as a result you have an array of arango objects now. Then you need to return these results in json format and we use json_encode() function for that job. but it will return an empty result. the reason is that arango document class does not implement JsonSerializable. a minor change will make everything easy and fun:

  1. adding this function at the end of Document.php public function jsonSerialize(array $options = []) { return $this->getAll($options); }

  2. change first line of class defenition class Document implements \JsonSerializable

jsteemann commented 6 years ago

Is this now addressed by #245 ?

a-shafaat commented 6 years ago

yes!

jsteemann commented 6 years ago

Ok, I will then close this issue. Thanks again for the PR!