GitHub PullRequestEvent at 2014-05-11 12:36:31
Repository: fractal
Actor: philsturgeon
Payload: {"action":"closed","number":45,"pull_request":{"url":"https://api.github.com/repos/thephpleague/fractal/pulls/45","id":15461232,"html_url":"https://github.com/thephpleague/fractal/pull/45","diff_url":"https://github.com/thephpleague/fractal/pull/45.diff","patch_url":"https://github.com/thephpleague/fractal/pull/45.patch","issue_url":"https://api.github.com/repos/thephpleague/fractal/issues/45","number":45,"state":"closed","title":"Implementation of configurable serializers.","user":{"login":"jasonlewis","id":829059,"avatar_url":"https://avatars.githubusercontent.com/u/829059?","gravatar_id":"f4b7a435c7db223f4a7462223dcfb568","url":"https://api.github.com/users/jasonlewis","html_url":"https://github.com/jasonlewis","followers_url":"https://api.github.com/users/jasonlewis/followers","following_url":"https://api.github.com/users/jasonlewis/following{/other_user}","gists_url":"https://api.github.com/users/jasonlewis/gists{/gist_id}","starred_url":"https://api.github.com/users/jasonlewis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasonlewis/subscriptions","organizations_url":"https://api.github.com/users/jasonlewis/orgs","repos_url":"https://api.github.com/users/jasonlewis/repos","events_url":"https://api.github.com/users/jasonlewis/events{/privacy}","received_events_url":"https://api.github.com/users/jasonlewis/received_events","type":"User","site_admin":false},"body":"This is a PR in relation to #24 and #18.\r\n\r\nSeeing as @joshuajabbour doesn't have the time at the moment to continue working on the PR I've had a crack at an implementation and would love some feedback.\r\n\r\n### The Implementation\r\n\r\nAt its core is the `SerializerInterface` which has 5 method signatures declared. Each serializer implements these methods to return the data in a format of their desire. Included is a basic `ArraySerializer`, which returns the data in what I consider an untouched form. Resulting JSON from the `ArraySerializer` would be:\r\n\r\n```json\r\n{\r\n    \"id\": 1,\r\n    \"name\": \"Bob\",\r\n    \"age\": 32,\r\n    \"embeds\": [\r\n        \"posts\"\r\n    ]\r\n}\r\n```\r\n\r\nBenefit here is for systems returning pre-keyed data (above would have the user data keyed to `user`, for example).\r\n\r\nThe default used serializer would be the (current) `DataArraySerializer` which keys the top level data to `data`.\r\n\r\n```json\r\n{\r\n    \"data\": {\r\n        \"id\": 1,\r\n        \"name\": \"Bob\",\r\n        \"age\": 32\r\n    },\r\n    \"embeds\": [\r\n        \"posts\"\r\n    ]\r\n}\r\n```\r\n\r\nThe serializer is set on the `Manager` via the `setSerializer` method.\r\n\r\n```php\r\n$manager = new League\\Fractal\\Manager;\r\n\r\n$manager->setSerializer(new League\\Fractal\\Serializer\\ArraySerializer);\r\n```\r\n\r\nIf no serializer is set the default `DataArraySerializer` is used.\r\n\r\n### Meta Data\r\n\r\nThis PR also includes meta data support for resources. Instead of defining a method on transformers I've opted for a (hopefully) better approach by setting the meta data on the resource.\r\n\r\n```php\r\n$user = new User('Bob', '23');\r\n\r\n$resource = new League\\Fractal\\Resource\\Item($user, new UserTransformer);\r\n\r\n$resource->setMeta(array('token' => 'kan1$isdd098hjasd89hsa#$9q'));\r\n```\r\n\r\nThe `ArraySerializer` simply merges with the top level much like it does with the standard data and the `DataArraySerializer` would key it to `meta` and merge to the top level.\r\n\r\n### Tests\r\n\r\nI've not done any tests yet merely patched the existing tests that failed due to the new meta data key. Will do tests once some more feedback is received on the approach and implementation.\r\n\r\nCheers.","created_at":"2014-05-03T09:34:39Z","updated_at":"2014-05-11T12:36:28Z","closed_at":"2014-05-11T12:36:28Z","merged_at":null,"merge_commit_sha":"64c2aa867e67fc103183f79e408ce99225968d3a","assignee":null,"milestone":{"url":"https://api.github.com/repos/thephpleague/fractal/milestones/1","labels_url":"https://api.github.com/repos/thephpleague/fractal/milestones/1/labels","id":564968,"number":1,"title":"0.8.x","description":null,"creator":{"login":"philsturgeon","id":67381,"avatar_url":"https://avatars.githubusercontent.com/u/67381?","gravatar_id":"14df293d6c5cd6f05996dfc606a6a951","url":"https://api.github.com/users/philsturgeon","html_url":"https://github.com/philsturgeon","followers_url":"https://api.github.com/users/philsturgeon/followers","following_url":"https://api.github.com/users/philsturgeon/following{/other_user}","gists_url":"https://api.github.com/users/philsturgeon/gists{/gist_id}","starred_url":"https://api.github.com/users/philsturgeon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philsturgeon/subscriptions","organizations_url":"https://api.github.com/users/philsturgeon/orgs","repos_url":"https://api.github.com/users/philsturgeon/repos","events_url":"https://api.github.com/users/philsturgeon/events{/privacy}","received_events_url":"https://api.github.com/users/philsturgeon/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":2,"state":"open","created_at":"2014-02-10T16:59:02Z","updated_at":"2014-05-11T12:36:28Z","due_on":null},"commits_url":"https://api.github.com/repos/thephpleague/fractal/pulls/45/commits","review_comments_url":"https://api.github.com/repos/thephpleague/fractal/pulls/45/comments","review_comment_url":"https://api.github.com/repos/thephpleague/fractal/pulls/comments/{number}","comments_url":"https://api.github.com/repos/thephpleague/fractal/issues/45/comments","statuses_url":"https://api.github.com/repos/thephpleague/fractal/statuses/c608090b317fd9eecafa2fd9480acebbf93ea99d","head":{"label":"jasonlewis:feature/serializer","ref":"feature/serializer","sha":"c608090b317fd9eecafa2fd9480acebbf93ea99d","user":{"login":"jasonlewis","id":829059,"avatar_url":"https://avatars.githubusercontent.com/u/829059?","gravatar_id":"f4b7a435c7db223f4a7462223dcfb568","url":"https://api.github.com/users/jasonlewis","html_url":"https://github.com/jasonlewis","followers_url":"https://api.github.com/users/jasonlewis/followers","following_url":"https://api.github.com/users/jasonlewis/following{/other_user}","gists_url":"https://api.github.com/users/jasonlewis/gists{/gist_id}","starred_url":"https://api.github.com/users/jasonlewis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasonlewis/subscriptions","organizations_url":"https://api.github.com/users/jasonlewis/orgs","repos_url":"https://api.github.com/users/jasonlewis/repos","events_url":"https://api.github.com/users/jasonlewis/events{/privacy}","received_events_url":"https://api.github.com/users/jasonlewis/received_events","type":"User","site_admin":false},"repo":{"id":19266845,"name":"fractal","full_name":"jasonlewis/fractal","owner":{"login":"jasonlewis","id":829059,"avatar_url":"https://avatars.githubusercontent.com/u/829059?","gravatar_id":"f4b7a435c7db223f4a7462223dcfb568","url":"https://api.github.com/users/jasonlewis","html_url":"https://github.com/jasonlewis","followers_url":"https://api.github.com/users/jasonlewis/followers","following_url":"https://api.github.com/users/jasonlewis/following{/other_user}","gists_url":"https://api.github.com/users/jasonlewis/gists{/gist_id}","starred_url":"https://api.github.com/users/jasonlewis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasonlewis/subscriptions","organizations_url":"https://api.github.com/users/jasonlewis/orgs","repos_url":"https://api.github.com/users/jasonlewis/repos","events_url":"https://api.github.com/users/jasonlewis/events{/privacy}","received_events_url":"https://api.github.com/users/jasonlewis/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jasonlewis/fractal","description":"Output complex, flexible, AJAX/RESTful data structures.","fork":true,"url":"https://api.github.com/repos/jasonlewis/fractal","forks_url":"https://api.github.com/repos/jasonlewis/fractal/forks","keys_url":"https://api.github.com/repos/jasonlewis/fractal/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jasonlewis/fractal/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jasonlewis/fractal/teams","hooks_url":"https://api.github.com/repos/jasonlewis/fractal/hooks","issue_events_url":"https://api.github.com/repos/jasonlewis/fractal/issues/events{/number}","events_url":"https://api.github.com/repos/jasonlewis/fractal/events","assignees_url":"https://api.github.com/repos/jasonlewis/fractal/assignees{/user}","branches_url":"https://api.github.com/repos/jasonlewis/fractal/branches{/branch}","tags_url":"https://api.github.com/repos/jasonlewis/fractal/tags","blobs_url":"https://api.github.com/repos/jasonlewis/fractal/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jasonlewis/fractal/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jasonlewis/fractal/git/refs{/sha}","trees_url":"https://api.github.com/repos/jasonlewis/fractal/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jasonlewis/fractal/statuses/{sha}","languages_url":"https://api.github.com/repos/jasonlewis/fractal/languages","stargazers_url":"https://api.github.com/repos/jasonlewis/fractal/stargazers","contributors_url":"https://api.github.com/repos/jasonlewis/fractal/contributors","subscribers_url":"https://api.github.com/repos/jasonlewis/fractal/subscribers","subscription_url":"https://api.github.com/repos/jasonlewis/fractal/subscription","commits_url":"https://api.github.com/repos/jasonlewis/fractal/commits{/sha}","git_commits_url":"https://api.github.com/repos/jasonlewis/fractal/git/commits{/sha}","comments_url":"https://api.github.com/repos/jasonlewis/fractal/comments{/number}","issue_comment_url":"https://api.github.com/repos/jasonlewis/fractal/issues/comments/{number}","contents_url":"https://api.github.com/repos/jasonlewis/fractal/contents/{+path}","compare_url":"https://api.github.com/repos/jasonlewis/fractal/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jasonlewis/fractal/merges","archive_url":"https://api.github.com/repos/jasonlewis/fractal/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jasonlewis/fractal/downloads","issues_url":"https://api.github.com/repos/jasonlewis/fractal/issues{/number}","pulls_url":"https://api.github.com/repos/jasonlewis/fractal/pulls{/number}","milestones_url":"https://api.github.com/repos/jasonlewis/fractal/milestones{/number}","notifications_url":"https://api.github.com/repos/jasonlewis/fractal/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jasonlewis/fractal/labels{/name}","releases_url":"https://api.github.com/repos/jasonlewis/fractal/releases{/id}","created_at":"2014-04-29T06:53:34Z","updated_at":"2014-05-11T12:36:28Z","pushed_at":"2014-05-11T10:58:00Z","git_url":"git://github.com/jasonlewis/fractal.git","ssh_url":"git@github.com:jasonlewis/fractal.git","clone_url":"https://github.com/jasonlewis/fractal.git","svn_url":"https://github.com/jasonlewis/fractal","homepage":"fractal.thephpleague.com","size":1750,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"thephpleague:master","ref":"master","sha":"9e1bd7195b7d0fbd8d4ae47ae1c1eb176817a24b","user":{"login":"thephpleague","id":527621,"avatar_url":"https://avatars.githubusercontent.com/u/527621?","gravatar_id":"18875aa293f692d34632520b76b4a0bc","url":"https://api.github.com/users/thephpleague","html_url":"https://github.com/thephpleague","followers_url":"https://api.github.com/users/thephpleague/followers","following_url":"https://api.github.com/users/thephpleague/following{/other_user}","gists_url":"https://api.github.com/users/thephpleague/gists{/gist_id}","starred_url":"https://api.github.com/users/thephpleague/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thephpleague/subscriptions","organizations_url":"https://api.github.com/users/thephpleague/orgs","repos_url":"https://api.github.com/users/thephpleague/repos","events_url":"https://api.github.com/users/thephpleague/events{/privacy}","received_events_url":"https://api.github.com/users/thephpleague/received_events","type":"Organization","site_admin":false},"repo":{"id":14732235,"name":"fractal","full_name":"thephpleague/fractal","owner":{"login":"thephpleague","id":527621,"avatar_url":"https://avatars.githubusercontent.com/u/527621?","gravatar_id":"18875aa293f692d34632520b76b4a0bc","url":"https://api.github.com/users/thephpleague","html_url":"https://github.com/thephpleague","followers_url":"https://api.github.com/users/thephpleague/followers","following_url":"https://api.github.com/users/thephpleague/following{/other_user}","gists_url":"https://api.github.com/users/thephpleague/gists{/gist_id}","starred_url":"https://api.github.com/users/thephpleague/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thephpleague/subscriptions","organizations_url":"https://api.github.com/users/thephpleague/orgs","repos_url":"https://api.github.com/users/thephpleague/repos","events_url":"https://api.github.com/users/thephpleague/events{/privacy}","received_events_url":"https://api.github.com/users/thephpleague/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/thephpleague/fractal","description":"Output complex, flexible, AJAX/RESTful data structures.","fork":false,"url":"https://api.github.com/repos/thephpleague/fractal","forks_url":"https://api.github.com/repos/thephpleague/fractal/forks","keys_url":"https://api.github.com/repos/thephpleague/fractal/keys{/key_id}","collaborators_url":"https://api.github.com/repos/thephpleague/fractal/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/thephpleague/fractal/teams","hooks_url":"https://api.github.com/repos/thephpleague/fractal/hooks","issue_events_url":"https://api.github.com/repos/thephpleague/fractal/issues/events{/number}","events_url":"https://api.github.com/repos/thephpleague/fractal/events","assignees_url":"https://api.github.com/repos/thephpleague/fractal/assignees{/user}","branches_url":"https://api.github.com/repos/thephpleague/fractal/branches{/branch}","tags_url":"https://api.github.com/repos/thephpleague/fractal/tags","blobs_url":"https://api.github.com/repos/thephpleague/fractal/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/thephpleague/fractal/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/thephpleague/fractal/git/refs{/sha}","trees_url":"https://api.github.com/repos/thephpleague/fractal/git/trees{/sha}","statuses_url":"https://api.github.com/repos/thephpleague/fractal/statuses/{sha}","languages_url":"https://api.github.com/repos/thephpleague/fractal/languages","stargazers_url":"https://api.github.com/repos/thephpleague/fractal/stargazers","contributors_url":"https://api.github.com/repos/thephpleague/fractal/contributors","subscribers_url":"https://api.github.com/repos/thephpleague/fractal/subscribers","subscription_url":"https://api.github.com/repos/thephpleague/fractal/subscription","commits_url":"https://api.github.com/repos/thephpleague/fractal/commits{/sha}","git_commits_url":"https://api.github.com/repos/thephpleague/fractal/git/commits{/sha}","comments_url":"https://api.github.com/repos/thephpleague/fractal/comments{/number}","issue_comment_url":"https://api.github.com/repos/thephpleague/fractal/issues/comments/{number}","contents_url":"https://api.github.com/repos/thephpleague/fractal/contents/{+path}","compare_url":"https://api.github.com/repos/thephpleague/fractal/compare/{base}...{head}","merges_url":"https://api.github.com/repos/thephpleague/fractal/merges","archive_url":"https://api.github.com/repos/thephpleague/fractal/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/thephpleague/fractal/downloads","issues_url":"https://api.github.com/repos/thephpleague/fractal/issues{/number}","pulls_url":"https://api.github.com/repos/thephpleague/fractal/pulls{/number}","milestones_url":"https://api.github.com/repos/thephpleague/fractal/milestones{/number}","notifications_url":"https://api.github.com/repos/thephpleague/fractal/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/thephpleague/fractal/labels{/name}","releases_url":"https://api.github.com/repos/thephpleague/fractal/releases{/id}","created_at":"2013-11-26T23:26:43Z","updated_at":"2014-05-11T12:35:43Z","pushed_at":"2014-05-11T12:35:42Z","git_url":"git://github.com/thephpleague/fractal.git","ssh_url":"git@github.com:thephpleague/fractal.git","clone_url":"https://github.com/thephpleague/fractal.git","svn_url":"https://github.com/thephpleague/fractal","homepage":"fractal.thephpleague.com","size":3065,"stargazers_count":330,"watchers_count":330,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":34,"mirror_url":null,"open_issues_count":2,"forks":34,"open_issues":2,"watchers":330,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/thephpleague/fractal/pulls/45"},"html":{"href":"https://github.com/thephpleague/fractal/pull/45"},"issue":{"href":"https://api.github.com/repos/thephpleague/fractal/issues/45"},"comments":{"href":"https://api.github.com/repos/thephpleague/fractal/issues/45/comments"},"review_comments":{"href":"https://api.github.com/repos/thephpleague/fractal/pulls/45/comments"},"review_comment":{"href":"https://api.github.com/repos/thephpleague/fractal/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/thephpleague/fractal/pulls/45/commits"},"statuses":{"href":"https://api.github.com/repos/thephpleague/fractal/statuses/c608090b317fd9eecafa2fd9480acebbf93ea99d"}},"merged":false,"mergeable":true,"mergeable_state":"clean","merged_by":null,"comments":31,"review_comments":24,"commits":11,"additions":840,"deletions":352,"changed_files":18}}