view:
formats: { json: true, xml: false, rss: false }
view_response_listener: true
+ mime_types:
+ json: ['application/json', 'application/json;version=1.0', 'application/json;version=2.0']
serializer:
serialize_null: true
format_listener:
rules:
- { path: '^/', priorities: ['json'], fallback_format: 'json' }
param_fetcher_listener: force
+ versioning:
+ enabled: true
+ resolvers:
+ media_type: # Accept header
+ enabled: true
+ regex: '/(v|version)=(?P<version>[0-9\.]+)/'
sensio_framework_extra:
view: { annotations: false }
class PersonController extends FOSRestController
{
/**
+ * @Rest\Prefix("/api")
* @Rest\Post(
* path = "/person/inscription",
* name = "create_person"
public function removePersonAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
- $person = $em->getRepository('App:Person')->find($request->get('id'));
+ $person = $em->getRepository('App::Person')->find($request->get('id'));
- if ($person) {
- $em->remove($place);
+ if (!empty($person)) {
+ $em->remove($person);
$em->flush();
}
}
$em = $this->getDoctrine()->getManager();
$person = $em->getRepository('App::Person')->find($request->get('id'));
- if (empty($place)) {
+ if (empty($person)) {
return new JsonResponse(['message' => 'Person not found'], Response::HTTP_NOT_FOUND);
}
* )
* @Rest\View()
*/
- public function showPerson(Person $person)
+ public function showPerson(Request $request)
{
+ $em = $this->getDoctrine()->getManager();
+ $person = $em->getRepository('App::Person')->find($request->get('id'));
+
+ if (empty($person)) {
+ return new JsonResponse(['message' => 'Person not found'], Response::HTTP_NOT_FOUND);
+ }
+
return $person;
}
* )
* @Rest\View()
*/
- public function showPersonByEmail(Person $person)
+ public function showPersonByEmail(Request $request)
{
+ $em = $this->getDoctrine()->getManager();
+ $person = $em->getRepository('App::Person')->find($request->get('email'));
+
+ if (empty($person)) {
+ return new JsonResponse(['message' => 'Person not found'], Response::HTTP_NOT_FOUND);
+ }
+
return $person;
}
* name = "show_person_friends",
* requirements = {"id"="\d+"}
* )
- * @Rest\View
+ * @Rest\View()
*/
- public function showPersonFriends(Person $person)
+ public function showPersonFriends(Request $request)
{
+ $em = $this->getDoctrine()->getManager();
+ $person = $em->getRepository('App::Person')->find($request->get('id'));
+
+ if (empty($person)) {
+ return new JsonResponse(['message' => 'Person not found'], Response::HTTP_NOT_FOUND);
+ }
+
return $person->getFriends();
}
* name = "show_person_friends_by_email",
* requirements = {"email"="\s+"}
* )
- * @Rest\View
+ * @Rest\View()
*/
- public function showPersonFriendsByEmail(Person $person)
+ public function showPersonFriendsByEmail(Request $request)
{
+ $em = $this->getDoctrine()->getManager();
+ $person = $em->getRepository('App::Person')->find($request->get('email'));
+
+ if (empty($person)) {
+ return new JsonResponse(['message' => 'Person not found'], Response::HTTP_NOT_FOUND);
+ }
+
return $person->getFriends();
}
}