{"action":"created","issue":{"url":"https://api.github.com/repos/zfcampus/zf-rest/issues/82","labels_url":"https://api.github.com/repos/zfcampus/zf-rest/issues/82/labels{/name}","comments_url":"https://api.github.com/repos/zfcampus/zf-rest/issues/82/comments","events_url":"https://api.github.com/repos/zfcampus/zf-rest/issues/82/events","html_url":"https://github.com/zfcampus/zf-rest/issues/82","id":90659459,"number":82,"title":"Wrong response code for creating entities without id or with id = 0","user":{"login":"Wilt","id":2419627,"avatar_url":"https://avatars.githubusercontent.com/u/2419627?v=3","gravatar_id":"","url":"https://api.github.com/users/Wilt","html_url":"https://github.com/Wilt","followers_url":"https://api.github.com/users/Wilt/followers","following_url":"https://api.github.com/users/Wilt/following{/other_user}","gists_url":"https://api.github.com/users/Wilt/gists{/gist_id}","starred_url":"https://api.github.com/users/Wilt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wilt/subscriptions","organizations_url":"https://api.github.com/users/Wilt/orgs","repos_url":"https://api.github.com/users/Wilt/repos","events_url":"https://api.github.com/users/Wilt/events{/privacy}","received_events_url":"https://api.github.com/users/Wilt/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-24T12:18:59Z","updated_at":"2015-07-07T21:29:45Z","closed_at":null,"body":"Wrong response code is returned when creating entities with id = 0 or entities without an id (composite key) because of an if clause in [line 384 in the RestController](https://github.com/zfcampus/zf-rest/blob/master/src/RestController.php#L384):\r\n\r\n```\r\n    if ($entity->id) {\r\n        $self = $entity->getLinks()->get('self');\r\n        $self = $plugin->fromLink($self);\r\n        $response = $this->getResponse();\r\n        $response->setStatusCode(201);\r\n        $response->getHeaders()->addHeaderLine('Location', $self);\r\n    }\r\n```\r\n\r\nWhat is the purpose of this if clause? Can it perhaps be replaced by the following:\r\n```\r\nif ($entity instanceof Entity){\r\n   ...\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/zfcampus/zf-rest/issues/comments/119347919","html_url":"https://github.com/zfcampus/zf-rest/issues/82#issuecomment-119347919","issue_url":"https://api.github.com/repos/zfcampus/zf-rest/issues/82","id":119347919,"user":{"login":"weierophinney","id":25943,"avatar_url":"https://avatars.githubusercontent.com/u/25943?v=3","gravatar_id":"","url":"https://api.github.com/users/weierophinney","html_url":"https://github.com/weierophinney","followers_url":"https://api.github.com/users/weierophinney/followers","following_url":"https://api.github.com/users/weierophinney/following{/other_user}","gists_url":"https://api.github.com/users/weierophinney/gists{/gist_id}","starred_url":"https://api.github.com/users/weierophinney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weierophinney/subscriptions","organizations_url":"https://api.github.com/users/weierophinney/orgs","repos_url":"https://api.github.com/users/weierophinney/repos","events_url":"https://api.github.com/users/weierophinney/events{/privacy}","received_events_url":"https://api.github.com/users/weierophinney/received_events","type":"User","site_admin":false},"created_at":"2015-07-07T21:29:45Z","updated_at":"2015-07-07T21:29:45Z","body":"I think the check for an identifier is because it's generally required in order to get the `self` relational link. However, I don't see anything in the code that should cause this to break; I'm going to try it now."}}