-
Notifications
You must be signed in to change notification settings - Fork 48
Allow to use custom document classes #208
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
Conversation
wrote some tests for custom document class, added documentClass to …
Thanks, @diabl0 for your PR. It looks fine on a quick code review, besides the issue with the JsonSerializer. See my comment https://github.com/arangodb/arangodb-php/pull/208/files#r103711888. |
lib/ArangoDBClient/Document.php
Outdated
@@ -19,7 +19,7 @@ | |||
* @package ArangoDBClient | |||
* @since 0.2 | |||
*/ | |||
class Document |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How did that get in? 😃
Implementation of JsonSerializable was rejected in PR #206 due to it adding a 70-100% overhead to object instantiation and handling (which does make a difference in a tight loop) and a way already exists to get the json-encoded data back (see #206 (comment)).
However, since your proposed changes allow subclassing, one has the choice to implement the JsonSerializer in a ny subclasses of Document
, used. That gives people the choice to keep a more lean base class, avoiding said overhead.
@frankmayer didn't noticed that discussion, so I removed \JsonSerializable from Document class itself and suggested using it in AbstractDocument in example implementation |
@diabl0 Great! Thank you again for your contribution. |
@frankmayer glad to help. |
Follow-up to #192
Allows to use custom document classes. This will enable to have some business logic associated with particular document types and helps with using ArangoDB documents in different frameworks like Symfony.
Sample use case can be found in examples/customDocumentClass.php