내가 코딩 한 것은 교리어떻게 특정 필드
한 사용자와 oneToMany 관계입니다 --->이 많은 통지
내가 데이터를 얻을 방법이있다
/**
* @Route("/test")
*/
public function testRoute()
{
//get the user notifications
$notifications = $this->getUser()->getNotifications();
//return json response
$serializer = $this->get('serializer');
$json = $serializer->serialize($notifications, 'json');
$response = new Response($json);
$response->headers->set('Content-Type', 'application/json');
return $response;
}
이 난 당신이 페이지를 얻을 생각 컨트롤러가
[
{
"id": 1,
"receiver": 1,
"notification_type": "new_comment",
"triggered_by": {
"id": 1,
"username": "gabriel",
"username_canonical": "gabriel",
"password": "3e6bS2I==",
"email": "[email protected]",
"first_name": "Gabriel",
"last_name": "ThaKid",
"likes_counter": 0,
"dislikes_counter": 2,
"favourites_counter": 0,
"profile_pic": "profilepic_60181.png",
"salt": "Lqch0N84UH1QmFI5O",
"form_token": "sO6NgWd",
"is_active": true,
"registration_confirmation": "success",
"secret_confirmation_id": "qTwNGm4CSKHzJOe8ry9DcXavt",
"socket_token": "KuMlxYHa"
},
"created_at": "2014-12-16T13:36:20+0100",
"link_to": "#test"
},
{
"id": 2,
"receiver": 1,
"notification_type": "new_comment",
"triggered_by": {
"id": 1,
"username": "gabriel",
"username_canonical": "gabriel",
"password": "3e6bS2IYX1DONLA/70a8hzMUQ==",
"email": "[email protected]",
"first_name": "Gabriel",
"last_name": "ThaKid",
"likes_counter": 0,
"dislikes_counter": 2,
"favourites_counter": 0,
"profile_pic": "profilepic_60181.png",
"profile_rank": "Beginner", (...)
},
"created_at": "2014-12-16T13:36:24+0100",
"link_to": "#test"
}
]
를 반환 것입니다 oint, 알맞은 특정 사용자의 알림을 반환합니다. 성도 및 성 같은 특정 필드가 사용자에게 필요하므로 반환 된 데이터를 응용 프로그램에서 사용할 수 있습니다. 그러나 doctrine은 토큰과 사용자가 알 필요가없는 정보와 함께 해시 된 암호와 소금을 반환합니다.
어떻게 doctrine이 필드를 반환하지 않겠다고 말합니까?
첫 번째 코드는 어떤 이유로 무한 루프를 반환했지만 JMS 번들은 – user3531149
@ user3531149 덕분에 해결되었습니다. 문서에서 직접 추측 한 것 자체는 기본 Serializer를 사용하지 않았습니다. – kix