{"action":"created","issue":{"url":"https://api.github.com/repos/FWM-Team/FWM-Backlog-Issues/issues/11","labels_url":"https://api.github.com/repos/FWM-Team/FWM-Backlog-Issues/issues/11/labels{/name}","comments_url":"https://api.github.com/repos/FWM-Team/FWM-Backlog-Issues/issues/11/comments","events_url":"https://api.github.com/repos/FWM-Team/FWM-Backlog-Issues/issues/11/events","html_url":"https://github.com/FWM-Team/FWM-Backlog-Issues/issues/11","id":62876711,"number":11,"title":"Object serialization","user":{"login":"FWAJL","id":7524388,"avatar_url":"https://avatars.githubusercontent.com/u/7524388?v=3","gravatar_id":"","url":"https://api.github.com/users/FWAJL","html_url":"https://github.com/FWAJL","followers_url":"https://api.github.com/users/FWAJL/followers","following_url":"https://api.github.com/users/FWAJL/following{/other_user}","gists_url":"https://api.github.com/users/FWAJL/gists{/gist_id}","starred_url":"https://api.github.com/users/FWAJL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FWAJL/subscriptions","organizations_url":"https://api.github.com/users/FWAJL/orgs","repos_url":"https://api.github.com/users/FWAJL/repos","events_url":"https://api.github.com/users/FWAJL/events{/privacy}","received_events_url":"https://api.github.com/users/FWAJL/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/FWM-Team/FWM-Backlog-Issues/labels/status:questions","name":"status:questions","color":"207de5"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-19T05:06:40Z","updated_at":"2015-03-19T05:59:17Z","closed_at":null,"body":"@damirius \r\n\r\nYour original comment:\r\n\r\nAs you know, I've implemented `IDocument` interface for `Entities` which contain files. So I had to add two new members, `webPath` and `absolutePath` to each `IDocument` class. I had to set them to private since our `BaseManager` is using public members to create queries. So when we do `json_encode` on those objects it will not encode everything that we need.\r\nI could add it to the IDocument interface and implement it in classes that use the mentioned interface, but I think this should be implemented somewhere in `Entity` abstract class since we could use it on other type of entity objects as well.\r\nWe just need some small method which we can use to specify which members to return.\r\nFor example `GetSerializable()` which will contain all members that we need to return as json later. Or we can even pass it some variable to see if we need to return, for example, just `id` and `name` or something more than that.\r\nAfter that we can call that method for each object and send it like that. \r\nWe can also use http://php.net/manual/en/jsonserializable.jsonserialize.php.\r\n\r\n**EDIT**: You can check out JsonSerializable interface implementation in Document DAO on feature_damir branch. Great thing about it is that we can just pass the object to the json_decode and jsonSerialize will be automatically called to provide the output. It works of course even with nested objects, you can check out `FileLoadController` in `Library\\Controllers` lines 47-53, is the old implementation where I had to manually assign the values to the output array and on line 44 `$list` is just the array of `Document` objects which is passed to the `fileResults`. \r\nProblematic thing is that if we implement it in Entity class we have to implement `jsonSerialize` method there too with some default return value. We can use get_object_var php function, but it will return all members so we maybe don't want to do that. We can also use `ReflecionObject` class to select only public ones since currently we are always displaying all public properties, then we can override the method of `Entity` class in specific classes that extend it and that have private properties.\r\n\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/FWM-Team/FWM-Backlog-Issues/issues/comments/83350383","html_url":"https://github.com/FWM-Team/FWM-Backlog-Issues/issues/11#issuecomment-83350383","issue_url":"https://api.github.com/repos/FWM-Team/FWM-Backlog-Issues/issues/11","id":83350383,"user":{"login":"FWAJL","id":7524388,"avatar_url":"https://avatars.githubusercontent.com/u/7524388?v=3","gravatar_id":"","url":"https://api.github.com/users/FWAJL","html_url":"https://github.com/FWAJL","followers_url":"https://api.github.com/users/FWAJL/followers","following_url":"https://api.github.com/users/FWAJL/following{/other_user}","gists_url":"https://api.github.com/users/FWAJL/gists{/gist_id}","starred_url":"https://api.github.com/users/FWAJL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FWAJL/subscriptions","organizations_url":"https://api.github.com/users/FWAJL/orgs","repos_url":"https://api.github.com/users/FWAJL/repos","events_url":"https://api.github.com/users/FWAJL/events{/privacy}","received_events_url":"https://api.github.com/users/FWAJL/received_events","type":"User","site_admin":false},"created_at":"2015-03-19T05:59:17Z","updated_at":"2015-03-19T05:59:17Z","body":"@damirius \r\n\r\nFirst, I am thankful for the initiative.\r\n\r\nNow, I think that the best solution is to have a default implementation in the class `Entity` so that it is done for all the classes. \r\nAs you describe it correctly, we need a way to get all the properties to serialize and it seems to me at  first glance the ReflectionObject is a good candidate to get the public properties only. It is true we don't want the private to be exposed.\r\nCan you implement this or you need help to do it?\r\n\r\nKeep up the good work.\r\n"}}